Skip to main content

Metrics

Struct Metrics 

Source
pub struct Metrics { /* private fields */ }
Expand description

Thread-safe metrics handle for in-process telemetry.

Implementations§

Source§

impl Metrics

Source

pub fn is_enabled(&self) -> bool

Whether this metrics instance currently records values.

Source

pub fn set_enabled(&self, enabled: bool)

Enable or disable metrics collection at runtime.

Source

pub fn snapshot(&self) -> MetricsSnapshot

Return a point-in-time snapshot of current metrics values.

Source

pub fn record_order_created(&self, _customer_id: &str, amount: f64)

Record a new order creation event.

Source

pub fn record_customer_created(&self, _customer_id: &str)

Record a new customer creation event.

Source

pub fn record_product_created(&self, _product_id: &str)

Record a new product creation event.

Source

pub fn record_return_requested(&self, _return_id: &str)

Record a new return request event.

Source

pub fn record_cart_created(&self, _cart_id: &str)

Record a new cart creation event.

Source

pub fn record_cart_checkout_completed(&self, _cart_id: &str, _order_id: &str)

Record a completed cart checkout event.

Source

pub fn record_shipment_created(&self, _shipment_id: &str)

Record a new shipment creation event.

Source

pub fn record_shipment_delivered(&self, _shipment_id: &str)

Record a shipment delivery event.

Source

pub fn record_subscription_created(&self, _subscription_id: &str)

Record a new subscription creation event.

Source

pub fn record_payment_completed(&self, _payment_id: &str, amount: f64)

Record a completed payment.

Source

pub fn record_inventory_adjusted(&self, _sku: &str, delta: f64)

Record an inventory adjustment.

Source

pub fn record_a2a_quote_created(&self)

Record an A2A quote creation.

Source

pub fn record_a2a_purchase_created(&self)

Record an A2A purchase creation.

Source

pub fn record_x402_intent_created(&self)

Record an x402 payment intent creation.

Source

pub fn record_x402_intent_settled(&self)

Record an x402 payment intent settlement.

Source

pub fn record_policy_evaluation(&self, denied: bool)

Record a policy evaluation.

Source

pub fn record_agent_registration(&self)

Record an agent registration.

Source

pub fn record_webhook_delivery(&self, failed: bool)

Record a webhook delivery attempt.

Source

pub fn record_pqc_signature(&self, profile: &str)

Record a PQC signature operation by security profile.

profile should be "legacy", "hybrid", or "pqc-strict".

Source

pub fn record_pqc_encryption(&self, profile: &str)

Record a PQC encryption operation by security profile.

profile should be "legacy", "hybrid", or "pqc-strict".

Source

pub fn record_request( &self, operation: &str, duration: Duration, is_error: bool, )

Record a request in RED metrics.

operation is normalized to a low-cardinality label.

Source

pub fn record_http_request( &self, method: &str, route: &str, status: u16, duration: Duration, )

Record an HTTP request in per-route RED metrics.

route should be a low-cardinality route pattern (e.g. axum’s MatchedPath such as /api/v1/orders/{id}), never a raw request path. 4xx and 5xx responses are counted separately; only 5xx responses are treated as errors for the global RED aggregate.

Source

pub fn record_request_success(&self, operation: &str, duration: Duration)

Record a successful request in RED metrics.

Source

pub fn record_request_error(&self, operation: &str, duration: Duration)

Record a failed request in RED metrics.

Trait Implementations§

Source§

impl Clone for Metrics

Source§

fn clone(&self) -> Metrics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Metrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Metrics

Source§

fn default() -> Metrics

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more