fix(otlptrace,otlpmetric): reject negative and overflowing timeout env values #9338
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
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.325
Real PR Conversation Timeline
1 comments
"Review active on #9338"
general
weight: 0.35
pellared
OTEL_EXPORTER_OTLP_TIMEOUT=-1gives the trace and metric OTLP exporters a timeout of -1ms, and so does9223372036854775807, because multiplying it bytime.Millisecondwraps around. The clients only set an export deadline whenexportTimeout > 0, so either value quietly removes the timeout and an export can wait until the caller's context ends. Nothing is logged.WithDurationininternal/shared/otlp/envconfig/envconfig.go.tmplnow rejects negative values and values abovemath.MaxInt64 / time.Millisecond. It reports them throughglobal.Errorand skips the value, so the default 10s timeout or a valid genericOTEL_EXPORTER_OTLP_TIMEOUTstays in effect. This matchesenvDurationinsdk/metric/env.go. Zero is still accepted as before.I switched the parse from
strconv.Atoitostrconv.ParseInt(v, 10, 64)so the overflow bound behaves the same on 32-bit targets. The template was regenerated withmake generateintootlptracegrpc,otlptracehttp,otlpmetricgrpcandotlpmetrichttp.This is the trace and metric counterpart of the log exporter fixes in #9254 and #9155, which only touch
otlploggrpcandotlploghttpand do not share this code.Testing: the shared
envconfig_test.go.tmplnow covers 0, -1, the largest accepted value 9223372036854, the first overflowing value 9223372036855, and the max int64. The shared trace and metricoptions_test.go.tmplcheck that a negative or overflowingOTEL_EXPORTER_OTLP_TIMEOUTleavesDefaultTimeoutin 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,gofmtandgolangci-lintv2.15.0 are clean for all four modules.