fix(telemetry): keep OTLP receiver alive 6s after Shutdown to flush gateway batch exporter - #1005
Conversation
|
@infer Can you finalise the work? prepare this PR for review (update body and title). use /go /go-concurrency /ponytail:ponytail |
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll tasks complete. Here's a summary of what was done: Changes madePR #1005 is now ready for review with updated title and body. Fixes to the salvage commitThe original salvage commit (
Ponytail simplificationInstead of adding a struct field (which would need a struct definition change and per-instance config nobody asked for), the fix uses the package-level variable directly in
No struct field, no per-instance config (YAGNI), one fewer indirection. Files changed (2 files, 14 insertions, 4 deletions)
Model: Tokens: 1,471,657 in · 9,461 out · 1,481,118 total (27 requests) Tool calls: 32 total · 97% success rate TracesStats
|
…istent struct field
|
🎉 This PR is included in version 0.160.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Resolves #1004 - gateway spans at the end of a session were silently dropped because the OTLP receiver shut down before the gateway's batch exporter (5s default delay) could flush pending spans.
Changes
internal/telemetry/recorder.go: Added areceiverGracePeriodpackage-level variable (6s, one batch window over the 5s default) and atime.Sleep(receiverGracePeriod)before closing the receiver server inShutdown(), giving the gateway time to deliver its last batch.internal/telemetry/main_test.go: OverridereceiverGracePeriod = 0inTestMainso tests return immediately instead of waiting 6s.Design notes
r.recvSrv != nil), so sessions without OTLP tracing are unaffected.Testing
go build ./internal/telemetry/passesgo test ./internal/telemetry/passes (grace period disabled in TestMain)task precommit:runpasses (fmt, lint, mod-tidy, markdownlint)