Repository navigation
fix(examples): reconnect the otel exporters after a dropped connection - #91
Merged
Merged
Conversation
Each exporter held one publication for the life of the process, so a broker restart silently ended a service's telemetry. Exporters now take a common.Publisher holding the stream's URI: it connects on the first batch, drops a connection that fails, and the next batch reconnects. A failed batch is still dropped, never raised, and one line is printed when telemetry starts being dropped and one when it recovers. Printed, not logged, so a record about a failing exporter cannot loop back through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FsSDkeb5rVAxA1FSmKKfQi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OTel exporters each held one
Publicationfor the life of the process. A broker restart therefore ended a service's telemetry for good, silently: every later batch failed against the closed connection, and OTel's SDK ignores aFAILUREresult.Change
common.Publisherreplaces thecommon.publish(publication, loop, rows)helper. It holds the stream's URI:exportevery half second (logs, spans) or every second (metrics), and that is the retry;Publisher:StreamLogExporter(publisher),StreamSpanExporter(publisher),StreamMetricExporter(publisher).services.exporting()builds one per stream and closes them at the end.exportreturnsFAILURE; nothing reaches the application.LoggingHandleron the root logger, a log record about a failing exporter would be exported through that same exporter. That's 8 lines.Tests
TestThePublisher. It sends a batch, stops the broker, sends twice (both returnFalse, nothing raises), restarts the broker on the same port and sends again.services.pyas separate processes, with the broker killed mid-run and restarted 5 s later. Each of the three streams printed one "dropped" line and one "published again" line. The producer kept taking orders throughout (36), with no tracebacks.🤖 Generated with Claude Code
https://claude.ai/code/session_01FsSDkeb5rVAxA1FSmKKfQi