Skip to content

feat(otel): optional OpenTelemetry (ActivitySource) tracing (ADR-0025)#2

Merged
muhammetsafak merged 1 commit into
mainfrom
feat/otel
Jun 19, 2026
Merged

feat(otel): optional OpenTelemetry (ActivitySource) tracing (ADR-0025)#2
muhammetsafak merged 1 commit into
mainfrom
feat/otel

Conversation

@muhammetsafak

Copy link
Copy Markdown
Member

The .NET mirror of the Go/Python/Node otel modules (ADR-0025): optional OpenTelemetry tracing as a BabelQueue.Tracing.Telemetry helper, built on System.Diagnostics.ActivitySource — the BCL primitive the OpenTelemetry .NET SDK consumes — so the core takes no OpenTelemetry package dependency and stays zero-dep. A consumer exports by adding the "BabelQueue" source to a TracerProvider (AddSource("BabelQueue")).

What

  • TraceIdOf/UuidOftrace_id (a UUID) ↔ ActivityTraceId (otherwise SHA-256). The already-propagated trace_id becomes the shared trace across every hop/SDK — no envelope change (GR-1).
  • Telemetry.Wrap(handler) — a CONSUMER Activity process <urn> in the trace_id-derived trace, with messaging-semconv tags + error recording. The handler still receives the full Envelope.
  • Telemetry.PublishAsync(urn, data, send) — a PRODUCER Activity publish <urn> that builds the envelope with the active trace's id as trace_id and runs the user's send within the activity.

Tests / gate

  • 6 new xUnit tests via an ActivityListener (mapping round-trip, consumer activity + tags, partial-envelope tolerance, error recording, producer stamping, producer error). dotnet test -c Release: 41 passed, 0 failed, 0 warnings (Roslyn analyzers + TreatWarningsAsErrors).
  • No new PackageReference; no <Version> bump.

Honest limit

One correlated trace per trace_id; exact cross-hop span parent-child (W3C traceparent as a transport header) is the documented follow-up.

🤖 Generated with Claude Code

Mirrors the Go/Python/Node otel modules: a BabelQueue.Tracing.Telemetry helper emitting produce/consume Activities correlated across hops via trace_id<->ActivityTraceId. Wrap (consumer activity) + PublishAsync (producer activity). Built on System.Diagnostics.ActivitySource (the BCL primitive the OpenTelemetry .NET SDK consumes), so the core takes no OpenTelemetry package dependency; a consumer exports by adding the "BabelQueue" source to a TracerProvider. Envelope untouched (GR-1); opt-in.
@muhammetsafak muhammetsafak merged commit 241815d into main Jun 19, 2026
6 checks passed
@muhammetsafak muhammetsafak deleted the feat/otel branch June 19, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant