← Back to Pull requests

fix(otlptrace,otlpmetric): reject negative and overflowing timeout env values #9338

Open
unknown opened this pull request with 229 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 04, 2026 13:28 UTC
Author

OTEL_EXPORTER_OTLP_TIMEOUT=-1 gives the trace and metric OTLP exporters a timeout of -1ms, and so does 9223372036854775807, because multiplying it by time.Millisecond wraps around. The clients only set an export deadline when exportTimeout > 0, so either value quietly removes the timeout and an export can wait until the caller's context ends. Nothing is logged.

WithDuration in internal/shared/otlp/envconfig/envconfig.go.tmpl now rejects negative values and values above math.MaxInt64 / time.Millisecond. It reports them through global.Error and skips the value, so the default 10s timeout or a valid generic OTEL_EXPORTER_OTLP_TIMEOUT stays in effect. This matches envDuration in sdk/metric/env.go. Zero is still accepted as before.

I switched the parse from strconv.Atoi to strconv.ParseInt(v, 10, 64) so the overflow bound behaves the same on 32-bit targets. The template was regenerated with make generate into otlptracegrpc, otlptracehttp, otlpmetricgrpc and otlpmetrichttp.

This is the trace and metric counterpart of the log exporter fixes in #9254 and #9155, which only touch otlploggrpc and otlploghttp and do not share this code.

Testing: the shared envconfig_test.go.tmpl now covers 0, -1, the largest accepted value 9223372036854, the first overflowing value 9223372036855, and the max int64. The shared trace and metric options_test.go.tmpl check that a negative or overflowing OTEL_EXPORTER_OTLP_TIMEOUT leaves DefaultTimeout in place, and that a negative signal-specific timeout keeps the generic one. The new rejection cases fail on main in all four modules (got -1ms, want 10s) and pass with the change.

Reverting only the non-test change makes them fail again.

go test -race ./..., go vet, gofmt and golangci-lint v2.15.0 are clean for all four modules.

Diff: 229 lines (+171 / -58) across 2 files Reviewer: pellared Review duration: 4166m
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 229 lines diff across 2 files
0.37
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.325
Real PR Conversation Timeline
1 comments
"Review active on #9338"
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: 37.0% (MEDIUM) · Higher = larger blast radius
37.0%
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.7% · Safe to merge
19.7%