pub struct OtelMetrics { /* private fields */ }otel only.Expand description
A Metrics implementation backed by OpenTelemetry instruments.
Records the following instruments:
| Instrument | Kind | Unit | Description |
|---|---|---|---|
rpc.server.call.duration | Histogram | s | Every inbound call, per the semantic conventions |
a2a.server.requests | Counter | {request} | Total inbound requests |
a2a.server.responses | Counter | {response} | Total outbound responses |
a2a.server.errors | Counter | {error} | Total errors |
a2a.server.request.duration | Histogram | s | Request duration in seconds (named a2a.server.latency before 0.15) |
a2a.server.queue_depth | Gauge | {queue} | Number of active event queues |
a2a.server.persistence_errors | Counter | {error} | Task writes that failed |
a2a.server.store_retries | Counter | {retry} | Store operations run again after a passing failure, by operation and cause |
a2a.server.push_deliveries | Counter | {delivery} | Push attempts, by outcome |
a2a.server.pool.active | Gauge | {connection} | Active (in-use) connections |
a2a.server.pool.idle | Gauge | {connection} | Idle connections |
a2a.server.pool.created | Counter | {connection} | Total connections created |
a2a.server.pool.closed | Counter | {connection} | Connections closed |
a2a.server.executor.duration | Histogram | s | How long an executor’s run took, by outcome (executor_outcome) |
rpc.server.call.duration carries rpc.system.name, rpc.method,
rpc.status_code and, on failure, error.type (see RpcCall). The
a2a.server.* counters and histogram carry a method attribute; the
error counter additionally carries an error attribute. Both histograms
use the conventions’ advisory buckets (RPC_DURATION_BUCKETS).
Implementations§
Source§impl OtelMetrics
impl OtelMetrics
Sourcepub fn with_tenant_dimension<S>(
self,
allowed: impl IntoIterator<Item = S>,
) -> OtelMetrics
pub fn with_tenant_dimension<S>( self, allowed: impl IntoIterator<Item = S>, ) -> OtelMetrics
Labels rpc.server.call.duration, a2a.server.executor.duration and
a2a.server.refusals with a2a.tenant: the tenant’s name when it is
one of allowed, _OTHER for any other tenant, and
no label for a request with none. Off by default; the series grow by
at most allowed.len() + 1 per existing series, which is the bound an
operator chooses here (audit H11).
Sourcepub fn with_agent_name(self, name: impl Into<String>) -> OtelMetrics
pub fn with_agent_name(self, name: impl Into<String>) -> OtelMetrics
Labels every a2a.server.* instrument this records, and
rpc.server.call.duration, with gen_ai.agent.name = name: for a
process serving several agents, one OtelMetrics per handler. Off by
default.
Source§impl OtelMetrics
impl OtelMetrics
Sourcepub fn from_meter(meter: &Meter) -> OtelMetrics
pub fn from_meter(meter: &Meter) -> OtelMetrics
Create an OtelMetrics from an already-configured [Meter].
Prefer OtelMetricsBuilder for typical usage.
Trait Implementations§
Source§impl Debug for OtelMetrics
impl Debug for OtelMetrics
Source§impl Metrics for OtelMetrics
impl Metrics for OtelMetrics
Source§fn on_request(&self, method: &str)
fn on_request(&self, method: &str)
Source§fn on_response(&self, method: &str)
fn on_response(&self, method: &str)
Source§fn on_error(&self, method: &str, error: &str)
fn on_error(&self, method: &str, error: &str)
Source§fn on_latency(&self, method: &str, duration: Duration)
fn on_latency(&self, method: &str, duration: Duration)
Source§fn on_queue_depth_change(&self, active_queues: usize)
fn on_queue_depth_change(&self, active_queues: usize)
Source§fn on_persistence_error(&self, operation: &str, error_kind: &str)
fn on_persistence_error(&self, operation: &str, error_kind: &str)
Source§fn on_store_retry(&self, operation: &str, cause: &str)
fn on_store_retry(&self, operation: &str, cause: &str)
cause = "unavailable", a turn’s event write, retried for
up to HandlerLimits::store_write_retry), or a PostgreSQL statement
lost its connection and ran once more on a fresh one
(operation = "statement", cause = "connection_lost"). Read moreSource§fn on_push_delivery(&self, outcome: &str)
fn on_push_delivery(&self, outcome: &str)
Source§fn on_connection_pool_stats(&self, stats: &ConnectionPoolStats)
fn on_connection_pool_stats(&self, stats: &ConnectionPoolStats)
Source§fn on_rpc_call(&self, call: &RpcCall<'_>)
fn on_rpc_call(&self, call: &RpcCall<'_>)
Source§fn on_executor_run(&self, outcome: &str, duration: Duration)
fn on_executor_run(&self, outcome: &str, duration: Duration)
Source§fn on_refusal(&self, cause: &str)
fn on_refusal(&self, cause: &str)
control::refusal. The same refusal is also an
on_error of class overloaded; this says which
limit or store refused it (audit H11).Source§fn on_lease(&self, event: &str)
fn on_lease(&self, event: &str)
control::lease.Source§fn on_halt(&self, scope: &str, action: &str, stopped: usize)
fn on_halt(&self, scope: &str, action: &str, stopped: usize)
scope is one of
control::halt_scope, action one of control::halt_action, and
stopped how many running tasks a halt stopped (0 for a resume).Source§fn on_steering(&self, outcome: &str)
fn on_steering(&self, outcome: &str)
control::steering. Read moreSource§fn on_claim(&self, event: &str)
fn on_claim(&self, event: &str)
control::claim.Source§fn on_subscribe_wake(&self, cause: &str)
fn on_subscribe_wake(&self, cause: &str)
SubscribeToTask stream that waits on a task’s event
log (a stream on a replica that does not run the task) stops waiting
to read the store again: cause is one of subscribe_wake. Read moreAuto Trait Implementations§
impl !Freeze for OtelMetrics
impl !RefUnwindSafe for OtelMetrics
impl !UnwindSafe for OtelMetrics
impl Forget for OtelMetrics
impl Move for OtelMetrics
impl Send for OtelMetrics
impl Sync for OtelMetrics
impl Unpin for OtelMetrics
impl UnsafeUnpin for OtelMetrics
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].