pub struct RouterBuilder { /* private fields */ }
Expand description
Routes metrics to specific target recorders.
Routes are defined as a prefix to check against the metric name, and a mask for the metric type. For example, a route with the pattern of “foo” would match “foo”, “or “foo.submetric”, but not “something.foo”. Likewise, a metric mask of “all” would apply this route to counters, gauges, and histograms, while any specific mask would only apply to the given metric kind.
A default route (recorder) is always present and used in the case that no specific route exists.
Implementations§
source§impl RouterBuilder
impl RouterBuilder
sourcepub fn from_recorder<R>(recorder: R) -> Selfwhere
R: Recorder + 'static,
pub fn from_recorder<R>(recorder: R) -> Selfwhere
R: Recorder + 'static,
Creates a RouterBuilder
from a Recorder
.
The given recorder is used as the default route when no other specific route exists.
sourcepub fn add_route<P, R>(
&mut self,
mask: MetricKindMask,
pattern: P,
recorder: R,
) -> &mut RouterBuilder
pub fn add_route<P, R>( &mut self, mask: MetricKindMask, pattern: P, recorder: R, ) -> &mut RouterBuilder
Adds a route.
mask
defines which metric kinds will match the given route, and pattern
is a prefix
string used to match against metric names.
If a matching route already exists, it will be overwritten.