Skip to main content

metric

Function metric 

Source
pub fn metric(ctx: &ServiceContext, name: &str, value: u64)
Expand description

Publish the current value of a named metric.

A metric is a set, not an increment: the sink keeps the last value published under (owner, name), and it keeps it after the publisher dies - a sample outliving its emitter is the one useful thing left to learn from a service that is gone.

The name is truncated past MET_NAME_LEN bytes, and a truncated name is a DIFFERENT name that can silently merge two metrics into one row. The SDK says so once per service rather than once per sample.

This cannot fail in a way a caller can act on, so it returns nothing: the sink is best-effort by design, and a dropped sample is retried on the next interval rather than failing the work that produced it.