← Back to Pull requests

fix(tracing): keep user-provided service source when DD_SERVICE equals inferred service #22073

Open
unknown opened this pull request with 210 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 24, 2026 17:20 UTC
Author

Why

When DD_SERVICE is 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_service and 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) becomes flask.

#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_finish now also requires that the service is not user-provided (not config._is_user_provided_service). This matches Config._get_service().

  • Updated 3 tests/opentelemetry/test_context.py snapshots. They run with DD_SERVICE set to the inferred name, so they had recorded the wrong _dd.svc_src: otel.
  • Impact

    When DD_SERVICE equals the inferred service name, spans now keep the user-provided service source instead of reporting the integration name. Nothing changes when DD_SERVICE is unset or differs from the inferred name. A release note is included.

    Testing

    test_service_source_for_inferred_base_service in tests/tracer/test_tracer.py:

  • A user-provided service equal to the inferred name keeps m. This case fails without the fix.

  • An inferred-only service still gets the integration name.
  • 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

    Diff: 210 lines (+157 / -53) across 2 files Reviewer: gnufede Review duration: 9471m
    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
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.5% (MEDIUM) · Higher = larger blast radius
    36.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.4% · Safe to merge
    19.4%