Skip to content

feat: force usage of ServiceWithSource in contrib#4549

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
mainfrom
raphael/net_http
Mar 16, 2026
Merged

feat: force usage of ServiceWithSource in contrib#4549
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
mainfrom
raphael/net_http

Conversation

@raphaelgavache

@raphaelgavache raphaelgavache commented Mar 16, 2026

Copy link
Copy Markdown
Member
  1. Add a test that enforces that ServiceWithSource is used in contrib
=== Failed
=== FAIL: instrumentation TestNoTracerServiceName (1.60s)
    contrib_test.go:223: Found 3 file(s) using tracer.ServiceName directly. All contrib packages should use instrumentation.ServiceNameWithSource instead, which provides service name source information for better precedence handling.
        Offending locations:
          contrib/net/http/internal/wrap/roundtrip.go:113
          instrumentation/httptrace/before_handle.go:56
          instrumentation/testutils/sql/sql.go:249
  1. support net/http with serviceSource, add a special option opt.wrap_handler dedicated to the custom API WrapHandler that sets service name
Screenshot 2026-03-16 at 14 48 52
  1. NB this increases the total memory benchmark of net/http in the case a service override is set, see below benchmark
Screenshot 2026-03-16 at 16 27 05

Motivation

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 make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

// // Create a root span.
// span, ctx := tracer.StartSpanFromContext(context.Background(), "parent.request",
// tracer.SpanType(ext.SpanTypeWeb),
// tracer.ServiceName("web"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the suggestion as it's not a recommended pattern

@github-actions github-actions Bot added the apm:ecosystem contrib/* related feature requests or bugs label Mar 16, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Mar 16, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 59.33% (+3.55%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dee5ad9 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov

codecov Bot commented Mar 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.10%. Comparing base (ab6160c) to head (fb307cd).

Additional details and impacted files
Files with missing lines Coverage Δ
instrumentation/testutils/sql/sql.go 0.00% <ø> (ø)

... and 433 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DataDog DataDog deleted a comment from pr-commenter Bot Mar 16, 2026
@raphaelgavache

Copy link
Copy Markdown
Member Author

@codex review

@raphaelgavache
raphaelgavache marked this pull request as ready for review March 16, 2026 19:17
@raphaelgavache
raphaelgavache requested review from a team as code owners March 16, 2026 19:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 066b179649

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
if cfg.ServiceName != "" {
opts = append(opts, tracer.ServiceName(cfg.ServiceName))
opts = append(opts, instrumentation.ServiceNameWithSource(cfg.ServiceName, cfg.ServiceSource))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve service source when span options override service

Using ServiceNameWithSource here can produce an incorrect _dd.svc_src when callers pass WithSpanOptions(tracer.ServiceName(...)) to WrapClient/WrapRoundTripper: the later span option overwrites the service name, but the source set by this call remains from cfg.ServiceSource, so the final span reports the wrong origin for the effective service override. This affects service-precedence behavior for any client instrumentation that customizes service via span options.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if customer add in addition of the config an option to set a service name, anwyways it will override the service name and source downstream (when patching tracer.ServiceName in following PR)

@DataDog DataDog deleted a comment from pr-commenter Bot Mar 16, 2026
@pr-commenter

pr-commenter Bot commented Mar 16, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-16 20:18:44

Comparing candidate commit dee5ad9 in PR branch raphael/net_http with baseline commit ab6160c in branch main.

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:BenchmarkHttpServeTrace-25

  • 🟥 allocated_mem [+411 bytes; +428 bytes] or [+4.519%; +4.701%]

@raphaelgavache

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants