Expand description
Telemetry: tracing spans, metrics, and structured events for client calls.
This is the transport-neutral instrumentation the client crates wrap their
RPCs with (Option B: telemetry lives in canton-core). Every instrumented
call opens a canton.rpc tracing span, emits request/error counters via
the metrics facade, and logs a structured success/error event.
Exporting. Following the standard Rust telemetry model, this crate
emits and the application chooses the exporters: a tracing_subscriber
for logs and spans, a metrics recorder for counters. Metrics carry
method + transport labels, so any recorder (Prometheus, an OTLP bridge,
…) gets the per-endpoint request/error breakdown for free (success =
requests − errors).
The otel feature supplies a supported OpenTelemetry path for both halves
rather than leaving it as an exercise: otel::otlp_tracer builds the span
exporter, otel::otlp_metrics builds the metrics pipeline and installs
the recorder that bridges this crate’s counters onto it, and trace context
is injected into every outgoing request — gRPC metadata, JSON headers, and
the WebSocket upgrade — automatically.
Streams. Use instrument for a call that returns a value and
instrument_stream for one that returns a stream. The difference is not
cosmetic: a subscription’s outcome is not known when it opens, so
instrumenting only the opening records every long-lived stream as a success
and never revisits it.
Modules§
- otel
otel - OpenTelemetry export helpers (enable the
otelfeature).
Constants§
- METRIC_
ERRORS - Counter: client errors, labelled by
method,transport, andretriable. - METRIC_
REQUESTS - Counter: total client requests, labelled by
methodandtransport. - TRANSPORT_
GRPC transportlabel / span-field value for the gRPC lane.- TRANSPORT_
JSON transportlabel / span-field value for the JSON lane.
Functions§
- current_
trace_ id - The current span’s trace id as 32 hex characters, when an OpenTelemetry context is active.
- instrument
- Instrument a client RPC future: open a
canton.rpcspan, count the request (and any error), and log a structured outcome event. - instrument_
stream - Instrument a client stream: the same span, counters and events as
instrument, but for the life of the stream rather than the moment it opens.