fix(otelhttp): set http.route on server spans when http.ServeMux populates Pattern #10417
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 248 lines diff across 3 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.330
Real PR Conversation Timeline
1 comments
"Review active on #10417"
general
weight: 0.35
dashpole
Description
Set the
http.routeattribute on server spans inotelhttpwhenhttp.Request.Patternis populated or updated duringnext.ServeHTTP(such as whenotelhttp.NewHandlerwraps anhttp.ServeMuxdirectly).Previously,
middleware.serveHTTPcalledRequestTraceAttrsbeforenext.ServeHTTP(whenr.Patternis empty). Afternext.ServeHTTPreturned, it updated the span name and passedrCtxtoRecordMetrics(so server metrics includedhttp.route), but never addedhttp.routeto the server span. Per the HTTP span semantic conventions, whenhttp.routebecomes available after span start, instrumentation must populate it before the span ends.The route update also runs during panic unwinding in the request
defer(matchingRouteMiddlewarebehavior) so matched routes that panic retain their span name andhttp.routeattribute.Part of #8415
Key Design Decisions
WithSpanOptionsoverrides whenr.Patternwas already populated:RequestTraceAttrsalready setshttp.routefromr.Patternbefore applyingWithSpanOptions. ComparingrCtx.Pattern != origReq.Patternskips redundantSetAttributescalls and avoids overwriting an explicithttp.routeattribute passed viaWithSpanOptionswhenPatterndid not change.RouteMiddlewareprecedence: Only falls back torCtx.PatternwhencapturedRoute == "", so an innerRouteMiddlewarematch still wins over a coarser outerServeMuxpattern.http.routeon empty or slash-less patterns: Usessemconv.HTTPRoute(rCtx.Pattern)and skips settinghttp.routeif empty.Alternatives Considered
span.SetAttributesunconditionally wheneverrCtx.Pattern != "": Simpler, but adds an unnecessarySetAttributescall on pre-routed handlers and would overwrite anhttp.routeattribute provided throughWithSpanOptions.