pub async fn initialize_metrics(
metrics_prefix: String,
default_level: Level,
) -> Result<(FilterHandle, MetricsFlusherWorker), GenericError>Expand description
Initializes the metrics subsystem with the given metrics prefix and default filter level.
default_level sets the initial filter level for emitted metrics, and is also what the filter is restored to when
FilterHandle::reset_filter is invoked. Metrics whose level is more verbose than this default are filtered out
until a runtime override is applied via FilterHandle::override_filter.
Returns a FilterHandle for adjusting the runtime metrics filter, plus a MetricsFlusherWorker
that must be added to a Supervisor in order to drive the periodic
flush loop. Internal metrics aren’t propagated to subscribers until the worker is running.
§Errors
If a global recorder was already installed, an error will be returned.