fix(tracing): keep user-provided service source when DD_SERVICE equals inferred service #22073
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 210 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.320
Real PR Conversation Timeline
1 comments
"Review active on #22073"
general
weight: 0.35
gnufede
Why
When
DD_SERVICEis set to the same value as the inferred service name, spans report the wrong service source (_dd.svc_src).At span finish, the tracer sees
span.service == config._inferred_base_serviceand treats the service as inferred, even though the user set it. It then overwrites the source with the integration name. For example,m(user-provided) becomesflask.#21693 fixes the same root cause for the service name in
int_service(). This PR fixes the service source. Neither PR depends on the other.What
ddtrace/_trace/tracer.py: the "service equals the inferred name" check in_on_span_finishnow also requires that the service is not user-provided (not config._is_user_provided_service). This matchesConfig._get_service().tests/opentelemetry/test_context.pysnapshots. They run withDD_SERVICEset to the inferred name, so they had recorded the wrong_dd.svc_src: otel.Impact
When
DD_SERVICEequals the inferred service name, spans now keep the user-provided service source instead of reporting the integration name. Nothing changes whenDD_SERVICEis unset or differs from the inferred name. A release note is included.Testing
test_service_source_for_inferred_base_serviceintests/tracer/test_tracer.py:m. This case fails without the fix.Risks
Low. The change adds one boolean check on the span-finish path, and it only runs when the span's service equals the inferred name.
🤖 Generated with Claude Code