Skip to main content

Module otel

Module otel 

Source
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

ModuleResponsibility
(this file)OtelMetrics struct and Metrics trait impl
builderOtelMetricsBuilder — fluent configuration
telemetryTelemetry — OTLP export of traces, metrics and logs from the OTEL_* environment (feature otlp)
pipelineinit_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.
OtelMetrics
A Metrics implementation backed by OpenTelemetry instruments.
OtelMetricsBuilder
Builder for OtelMetrics.
PrometheusScrape
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::init or Telemetry::builder.
TelemetryBuilder
Configures and builds a Telemetry; see Telemetry::builder.

Enums§

ConsoleFormat
The format of the lines install_subscriber prints.
OtlpCompression
How the body of an export request is compressed. Without one, it is not.
OtlpProtocol
The OTLP transport.
TelemetryError
Why Telemetry could 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_pipelineDeprecated
Initialise an OTLP metrics export pipeline and install it as the global MeterProvider.
init_otlp_pipeline_with_endpointDeprecated
init_otlp_pipeline with the collector endpoint given explicitly instead of read from OTEL_EXPORTER_OTLP_ENDPOINT.