Skip to main content

Module otel

Module otel 

Source
Expand description

OpenTelemetry integration for the A2A server.

This module provides OtelMetrics, an implementation of the Metrics trait that records request counts, error counts, latency histograms, and queue depth to OpenTelemetry instruments. Data is exported via the OTLP protocol (gRPC) using the opentelemetry-otlp crate.

§Module structure

ModuleResponsibility
(this file)OtelMetrics struct and Metrics trait impl
builderOtelMetricsBuilder — fluent configuration
pipelineinit_otlp_pipeline — OTLP export setup

§Feature flag

This module is only available when the otel feature is enabled.

§Quick start

use a2a_protocol_server::otel::{OtelMetrics, OtelMetricsBuilder, init_otlp_pipeline};

// 1. Initialise the OTLP export pipeline (sets the global MeterProvider).
let provider = init_otlp_pipeline("my-a2a-agent")?;

// 2. Build the metrics instance.
let metrics = OtelMetricsBuilder::new()
    .meter_name("a2a.server")
    .build();

// 3. Pass `metrics` to `RequestHandlerBuilder::metrics(metrics)`.

Structs§

OtelMetrics
A Metrics implementation backed by OpenTelemetry instruments.
OtelMetricsBuilder
Builder for OtelMetrics.

Functions§

init_otlp_pipeline
Initialise an OTLP metrics export pipeline and install it as the global MeterProvider.