Add _dd.svc_src to distinguish source#5778
Conversation
|
Thank you for updating Change log entry section 👏 Visited at: 2026-05-19 12:52:01 UTC |
Typing analysisThis PR does not change typing compared to the base branch. |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 539a132 | Docs | Datadog PR Page | Give us feedback! |
426ca31 to
cef8ea3
Compare
BenchmarksBenchmark execution time: 2026-05-28 08:54:45 Comparing candidate commit 539a132 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 1 unstable metrics.
|
cef8ea3 to
a4bff46
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32b3f85653
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
7638637 to
e21c2eb
Compare
e21c2eb to
e459e32
Compare
`reset_subscription_state!` previously cleared the patcher's `@patch_only_once` flag so the next `Datadog.configure` call would re-run the patcher and rebuild subscriptions with fresh span options. This caused ActionCable tests to fail on Ruby 3.4: re-running the patcher re-includes `Instrumentation::ActionCableChannel` into `ActionCable::Channel::Base`, which re-fires `included` and appends duplicate `set_callback` entries every test, accumulating spans. The helper now takes a block to wrap the caller's `Datadog.configure`, then explicitly calls `events_module.subscribe!` to refresh subscriptions without touching `@patch_only_once`. All affected specs are updated to the new block form with matching `after` cleanup.
The 'service_name is overridden' context configures `c.tracing.instrument :hanami, service_name: 'custom-hanami'` but nothing resets it afterwards. Under randomized order, later tests that expect `tracer.default_service` instead saw 'custom-hanami'. Hanami tracers read `Datadog.configuration.tracing[:hanami]` at request time (no ActiveSupport::Notifications subscription cache to refresh), so a plain `reset_configuration!` in the shared context's `after` hook is enough — no need for `reset_subscription_state!`.
`reset_subscription_state!` calls `Subscription#unsubscribe_all`, which goes through `ActiveSupport::Notifications.unsubscribe(subscriber)`. Fanout's `unsubscribe` does `subscriber.try(:pattern)`. AS 7.0+ requires `active_support/core_ext/object/try` at the top of `fanout.rb` itself. AS 6.x does not and relies on the host application having loaded the core_ext elsewhere (Rails apps do; our test bundle does not on Ruby 2.6 + AS 6.0.6.1, which surfaces as `NoMethodError: undefined method 'try' for Fanout::Subscribers::Evented`). Require `try` lazily inside the helper so AS-free contrib specs (redis, mongo, net_http, ...) are unaffected.
What does this PR do?
Adds a new
_dd.svc_srctag on spans whose service name has been overridden from the global default service. The value identifies the source of the override: the integration component name (e.g.redis,pg,sidekiq) for Datadog-instrumented spans, ormfor manually-instrumented spans.The tag is set in each contrib alongside the existing
span.service =override, and a fallbackmvalue is applied in thespan_before_finishhook for any service-overridden span that does not already carry the tag. The tag is removed when the span's service ends up matching the global default service.This complements the existing
_dd.base_servicetag, which records the global default service when a span overrides it.Motivation:
Backends and downstream consumers need to distinguish manually-set service overrides from those applied by Datadog integrations, so they can attribute service-naming behavior correctly.
Change log entry
None.
Additional Notes:
This PR is stacked on top of
tonycthsu/before_finish_event— please review and merge that branch first. The fallbackmtagging relies on thespan_before_finishevent introduced there.How to test the change?
service_nameconfigured — span should carry_dd.svc_src = redis.Tracing.trace('op', service: 'custom') { ... }— span should carry_dd.svc_src = m._dd.svc_src.