feat(otel): optional OpenTelemetry tracing (ADR-0025)#2
Merged
Conversation
Mirrors the Go reference (babelqueue-go/otel): a new babelqueue.otel module (importable only with the [otel] extra, so the core stays dependency-free) emitting produce/consume spans correlated across hops via trace_id<->OTel TraceID. wrap_handler (consumer span) + publish (producer span). CI installs [otel]+opentelemetry-sdk so the tests run under the coverage gate. Envelope untouched (GR-1); opt-in.
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 Python mirror of
babelqueue-go/otel(ADR-0025): optional OpenTelemetry tracing as a newbabelqueue.otelmodule, importable only with the[otel]extra so the core stays dependency-free (GR-7).What
trace_id↔ 128-bit OTel trace id (a UUID maps to its bytes; otherwise SHA-256). The already-propagatedtrace_idbecomes the shared OTel trace across every hop/SDK — no envelope change (GR-1).wrap_handler(tracer, handler)— a CONSUMER spanprocess <urn>in thetrace_id-derived trace, with messaging-semconv attributes + error recording. Its*argssignature makes the runtime pass the full envelope, so it readstrace_id/jobeven when the inner handler only wants(data, meta).publish(tracer, app, urn, data)— a PRODUCER spanpublish <urn>that carries the active trace into the message'strace_id.Tests / CI
babelqueue.otelat 100% line coverage; ruff + mypy clean.[otel]extra +opentelemetry-sdkin the test/lint/coverage jobs so the suite runs under the existing--cov-fail-under=90gate.Honest limit
One correlated trace per
trace_id; exact cross-hop span parent-child (W3Ctraceparentas a transport header) is the documented follow-up.🤖 Generated with Claude Code