← Back to Pull requests

Read stable HTTP semconv attributes when building HTTP span messages #2516

Closed
unknown closed this pull request without merging on Oct 06, 2026 21:27 UTC
View on GitHub
unknown unknown commented on Oct 06, 2026 13:13 UTC
Author

Fixes #2513 (the second half; #2514 handled the stale message after update_name).

What

_tweak_http_spans now understands the stable HTTP semantic conventions as well as the old ones:

| old | stable |
|---|---|
| http.method | http.request.method |
| http.target | url.path |
| query parsed from http.url | url.query |
| http.url | url.full |

The old keys still take precedence when both are present (as with OTEL_SEMCONV_STABILITY_OPT_IN=http/dup), so spans from the contrib instrumentations are unchanged.

Why

FastAPI's built-in telemetry (0.142+) starts the server span as GET with only the stable attributes, then renames it to GET /items/{item_id} once routing has matched. After #2514 the message followed the rename, but _tweak_http_spans only read the old keys, so it found just http.route and left the message as GET /items/{item_id} instead of building GET /items/1.

Details

  • The query string now comes from url.query when present, otherwise it's parsed from the URL as before, and is rendered the same way (/path ? a='1' & b='2 3').

  • http.target is still derived from http.url for spans on the old conventions, but is not added to spans that only use url.full, to avoid mixing deprecated attributes into stable-semconv spans.
  • Before / After

    Real FastAPI 0.142.2 with its built-in telemetry, GET /items/1?x=1&y=2:

    main:  name='GET /items/{item_id}'  logfire.msg='GET /items/{item_id}'
    PR:    name='GET /items/{item_id}'  logfire.msg="GET /items/1 ? x='1' & y='2'"
    

    Tests

    Added test_http_spans_stable_semconv in tests/test_logfire.py covering a renamed server span with a query string, a server span without one, and client spans with and without server.address. The lockfile pins FastAPI 0.141.1 which has no built-in telemetry, so the test drives the tracer directly the same way #2514's test does; the FastAPI 0.142.2 output above was checked manually.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_013cgYhnUKiuH97ZvDynSqgf

    <!-- This is an auto-generated description by cubic. -->
    <a href="https://cubic.dev/pr/pydantic/logfire/pull/2516?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
    <!-- End of auto-generated description by cubic. -->

    Diff: 333 lines (+249 / -84) across 4 files Reviewer: samuelcolvin Review duration: 494m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 333 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2516"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.7% · Safe to merge
    16.7%