ARCP uses W3C Trace Context (spec §11). The SDK exposes instrumentation via
System.Diagnostics.ActivitySource — no OpenTelemetry SDK dependency in the
core library. Arcp.Otel provides the transport wrapper and attribute
constants.
-
Add the
Arcp.Otelpackage:dotnet add package Arcp.Otel
-
Wrap your transport with
WithTracing():using Arcp.Otel; // Server side: _ = server.AcceptAsync(serverTransport.WithTracing()); // Client side: await using var client = await ArcpClient.ConnectAsync( clientTransport.WithTracing(), options);
-
Register the
ActivitySourcenames with your OTel SDK consumer:using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource(ArcpDiagnostics.TransportSourceName) // "Arcp.Transport" .AddSource(ArcpDiagnostics.RuntimeSourceName) // "Arcp.Runtime" .AddOtlpExporter() .Build();
| Name | Purpose |
|---|---|
Arcp.Transport |
One span per envelope (send and receive). |
Arcp.Runtime |
Application spans you start manually (e.g. delegation). |
For each envelope, the wrapper:
- Starts an
Activitynamedarcp.send {type}(producer) orarcp.recv {type}(consumer). - Sets the attribute keys listed below.
- On send: injects a W3C
traceparent(andtracestateif present) intoenvelope.extensions["x-vendor.opentelemetry.tracecontext"]. - On receive: extracts the same field and restores it as the parent
ActivityContextbefore starting the consumer span.
| Attribute | Source field |
|---|---|
arcp.direction |
"in" / "out" |
arcp.type |
envelope type |
arcp.id |
envelope id |
arcp.session_id |
envelope session_id |
arcp.job_id |
envelope job_id |
arcp.trace_id |
envelope trace_id |
arcp.event_seq |
envelope event_seq |
Arcp.AspNetCore does not have a built-in transport hook. To
instrument the server side, wrap the ArcpServer.AcceptAsync call
yourself with a WithTracing()-wrapped transport, or call WithTracing
on the client transport before passing it to ArcpClient.ConnectAsync:
var transport = new WebSocketTransport(socket, ownsSocket: true).WithTracing();
await using var client = await ArcpClient.ConnectAsync(transport, options);The runtime reads the ambient Activity.Current when emitting
envelopes. Run a child submit inside an activity scope to inherit the
parent's trace context:
using var activity = ArcpDiagnostics.Runtime.StartActivity("delegate.research");
var child = await childClient.SubmitAsync("research", input: new { topic });ctx.TraceId is available as a read-only view of the parent's trace
identifier when you need to log it. See Delegation
for the full pattern.
See samples/Tracing/ for a runnable sample
that exports spans to an OTLP collector.