Skip to content

fix(ddtrace/tracer): handle nil options in span configuration functions#3592

Merged
kakkoyun merged 6 commits into
mainfrom
dario.castane/issue-3558
Jun 4, 2025
Merged

fix(ddtrace/tracer): handle nil options in span configuration functions#3592
kakkoyun merged 6 commits into
mainfrom
dario.castane/issue-3558

Conversation

@darccio

@darccio darccio commented Jun 4, 2025

Copy link
Copy Markdown
Member

What does this PR do?

Added checks to skip nil options in the Finish and SpanStart functions to prevent potential runtime errors when processing options.

Motivation

Closes #3558

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running golangci-lint run locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

Added checks to skip nil options in the Finish and SpanStart functions to prevent potential runtime errors when processing options.
@pr-commenter

pr-commenter Bot commented Jun 4, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-06-04 15:18:53

Comparing candidate commit 7897c4a in PR branch dario.castane/issue-3558 with baseline commit f90e8ba in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 21 metrics, 0 unstable metrics.

…tions

Introduced new test cases for the Finish and StartSpan functions to verify correct behavior when provided with nil options. These tests ensure that nil options are handled gracefully without causing runtime errors, enhancing the robustness of the span configuration.
@darccio
darccio marked this pull request as ready for review June 4, 2025 08:49
@darccio
darccio requested a review from a team as a code owner June 4, 2025 08:49
@kakkoyun
kakkoyun enabled auto-merge (squash) June 4, 2025 13:04
darccio added 3 commits June 4, 2025 17:01
…ests

Updated test function signatures in span tests to use a blank identifier for the testing.T parameter, improving code clarity and consistency. This change does not affect test functionality but enhances readability.
@hannahkm

hannahkm commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

We have similar code in each of the contribs (i.e. whenever we call fn.apply(cfg)). Should we be adding nil checks there too?

@darccio

darccio commented Jun 4, 2025

Copy link
Copy Markdown
Member Author

We have similar code in each of the contribs (i.e. whenever we call fn.apply(cfg)). Should we be adding nil checks there too?

Yes, but let's do it in upcoming PRs. The odds of somebody explicitly passing a nil option to the tracer API is already quite low. I can imagine that for any given contrib being used in this way the odds are even lower. With this PR we cover the most usual APIs.

@kakkoyun
kakkoyun merged commit 50408ab into main Jun 4, 2025
190 checks passed
@kakkoyun
kakkoyun deleted the dario.castane/issue-3558 branch June 4, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: span.Finish panics if mistakenly given a nil option

3 participants