Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

End-to-end OpenTelemetry: every envelope on the wire (in either
direction) emits a span, and W3C trace context (`traceparent` /
`tracestate`) rides along inside `envelope.extensions["x.otel"]` so
the spans link into one distributed trace.
`tracestate`) rides along inside
`envelope.extensions["x-vendor.opentelemetry.tracecontext"]` so the
spans link into one distributed trace.

The middleware MUST be wired on **both** sides. If only one side wires
it, that side's spans are correct in isolation, but the peer creates
Expand Down Expand Up @@ -70,5 +71,6 @@ Tempo, Honeycomb, or any OTLP receiver.

## Spec sections

- §11 Trace propagation (W3C context via `extensions["x.otel"]`)
- §11 Trace propagation (W3C context via
`extensions["x-vendor.opentelemetry.tracecontext"]`)
- §10.3 trace inheritance on delegation
2 changes: 1 addition & 1 deletion examples/tracing/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Wires `@agentruntimecontrolprotocol/middleware-otel` into the client transport so spans on
* the submit path link end-to-end with the server's spans via W3C trace
* context carried in `extensions["x.otel"]`.
* context carried in `extensions["x-vendor.opentelemetry.tracecontext"]`.
*
* Run after `server.ts`:
* pnpm tsx examples/tracing/client.ts
Expand Down
7 changes: 4 additions & 3 deletions examples/tracing/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* Tracing example — server.
*
* Wires `@agentruntimecontrolprotocol/middleware-otel` into the runtime side so every inbound
* frame extracts the W3C trace context from `extensions["x.otel"]` and
* every outbound frame injects one. Spans are exported to the console
* via `ConsoleSpanExporter` — no collector required.
* frame extracts the W3C trace context from
* `extensions["x-vendor.opentelemetry.tracecontext"]` and every outbound
* frame injects one. Spans are exported to the console via
* `ConsoleSpanExporter` — no collector required.
*/

import {
Expand Down
13 changes: 8 additions & 5 deletions packages/middleware/otel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
*
* - Outbound `send` calls produce a `arcp.send` span with the envelope
* type/id/session_id as attributes, and the active trace context is
* injected into the envelope's `extensions["x.otel"]` field (W3C
* traceparent + tracestate) so the peer can continue the trace.
* injected into the envelope's
* `extensions["x-vendor.opentelemetry.tracecontext"]` field (W3C
* `traceparent` + `tracestate`) so the peer can continue the trace.
* - Inbound frames produce a `arcp.recv` span, extracting any
* `extensions["x.otel"]` trace context so the inbound frame appears
* as a child of the originating span on the remote end.
* `extensions["x-vendor.opentelemetry.tracecontext"]` trace context so
* the inbound frame appears as a child of the originating span on the
* remote end.
*
* Wire it on either side:
* ```ts
Expand Down Expand Up @@ -50,7 +52,8 @@ const OTEL_EXTENSION_NAME = "x-vendor.opentelemetry.tracecontext" as const;

/**
* Wrap a {@link Transport} so each frame produces a span and W3C trace
* context is propagated through `envelope.extensions["x.otel"]`.
* context is propagated through
* `envelope.extensions["x-vendor.opentelemetry.tracecontext"]`.
*
* The returned transport satisfies the same interface, so it is a drop-in
* for `ARCPServer.accept(...)` / `ARCPClient.connect(...)`.
Expand Down