Available on crate feature
otel only.Expand description
OpenTelemetry integration for the A2A server.
This module provides OtelMetrics, an implementation of the Metrics
trait that records the server’s counters, histograms and gauges (the
catalogue is in the book’s Observability chapter) to OpenTelemetry
instruments, through the OpenTelemetry API only: to the meter provider the
process has installed, or to nothing. Telemetry (feature otlp) installs
providers that export metrics, traces and logs over OTLP/HTTP or gRPC.
§Module structure
| Module | Responsibility |
|---|---|
| (this file) | OtelMetrics struct and Metrics trait impl |
builder | OtelMetricsBuilder — fluent configuration |
telemetry | Telemetry — OTLP export of traces, metrics and logs from the OTEL_* environment (feature otlp) |
pipeline | init_otlp_pipeline / init_otlp_pipeline_with_endpoint — the older metrics-only, gRPC-only setup, deprecated since 0.16.0 |
§Feature flags
otel (on by default) gives OtelMetrics and OtelMetricsBuilder,
which record through the OpenTelemetry API: to the provider the process
installs, or to nothing. otlp adds what exports them: Telemetry, the
Langfuse preset and init_otlp_pipeline.
§Quick start
// `Telemetry` needs the `otlp` feature (on by default in
// `a2a-protocol-sdk`).
use a2a_protocol_server::otel::Telemetry;
// Exports each signal the `OTEL_*` environment names an endpoint for, and
// installs the global providers. Handlers built with no `with_metrics`
// record through `OtelMetrics` to them; there is nothing to pass.
let telemetry = Telemetry::builder()
.with_default_service_name("my-a2a-agent")
.with_export_where_configured()
.build()?;
telemetry.install_subscriber();
// Dropping `telemetry` (or `telemetry.shutdown()`) flushes.Structs§
- Langfuse
- Where traces go, and the project keys that authorise them.
- Otel
Metrics - A
Metricsimplementation backed by OpenTelemetry instruments. - Otel
Metrics Builder - Builder for
OtelMetrics. - Prometheus
Scrape - The metrics in the Prometheus text format, for an application to serve.
- Telemetry
- Exporting providers for traces, metrics and logs, and the guard that
flushes them. Built by
Telemetry::initorTelemetry::builder. - Telemetry
Builder - Configures and builds a
Telemetry; seeTelemetry::builder.
Enums§
- Console
Format - The format of the lines
install_subscriberprints. - Otlp
Compression - How the body of an export request is compressed. Without one, it is not.
- Otlp
Protocol - The OTLP transport.
- Telemetry
Error - Why
Telemetrycould not be built, or lost telemetry.
Constants§
- LANGFUSE_
SELF_ HOSTED - Where a self-hosted Langfuse listens when started from its own
docker-compose.yml;Langfuse::from_env’s default. - RPC_
DURATION_ BUCKETS - The RPC call-duration buckets the semantic conventions advise, in seconds.
Functions§
- init_
otlp_ pipeline Deprecated - Initialise an OTLP metrics export pipeline and install it as the global
MeterProvider. - init_
otlp_ pipeline_ with_ endpoint Deprecated init_otlp_pipelinewith the collector endpoint given explicitly instead of read fromOTEL_EXPORTER_OTLP_ENDPOINT.