fix(otlp-http): record one terminal ExporterMetrics outcome per export #1347
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.42) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 332 lines diff across 4 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
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1347"
general
weight: 0.35
aranhave
Summary
Fixes #1212.
When an OTLP/HTTP
exportorflushtimed out, the waiting caller calledexporterMetrics?.addFailed(value:)and returned.failure. If the HTTP client invoked its completion handler later, the callback calledaddSuccessoraddFailedagain for the same attempt, producing double-counted outcomes (failed=2, orfailed=1andsuccess=1).This adds a shared
OtlpHttpExporterBase.send(_:timeout:metrics:count:onSuccess:onFailure:)helper and updatesexportandflushacrossOtlpHttpTraceExporter,OtlpHttpLogExporter, andOtlpHttpMetricExporterto use it:ExporterMetricsoutcome (addSuccessif the request finishes before the timeout and succeeds,addFailedotherwise).requeueon export failure,dropFlushedon flush success) and error feedback without recording a second metric outcome.Testing
Ran locally on macOS (Swift 6.4.2):
Added
ExporterMetricsCoverageTests.testLateHTTPCompletionsDoNotRecordAnotherOutcome, covering timed-outexportwith a late failure and timed-outflushwith a late200response acrossOtlpHttpTraceExporter,OtlpHttpLogExporter, andOtlpHttpMetricExporter(asserting 6 failed outcomes and 0 success outcomes total).Limitations
ExporterMetricsAPI (addSeen,addSuccess,addFailed) unchanged for source compatibility and enforces single-outcome recording inOtlpHttpExporterBase.send.requeue/dropFlushed) to keep existing retry behavior intact.Checklist
swift test --enable-all-traitspasses locallyTests/IntegrationTestsare updated. Anything that adds, removes orrenames a span, log record, event name, or attribute emitted by an
instrumentation (
Sources/Instrumentation/**) must be exercised byIntegrationTestScenarioinExamples/HackerNewsDemoand asserted onin
Tests/IntegrationTests/Assertions. Runmake integ-tests-iostoverify, and see
Tests/IntegrationTests/README.md.