penumbra_sdk_funding::component::metrics

Function set_default_local_recorder

Source
pub fn set_default_local_recorder(
    recorder: &dyn Recorder,
) -> LocalRecorderGuard<'_>
Available on crate feature component only.
Expand description

Sets the recorder as the default for the current thread for the duration of the lifetime of the returned LocalRecorderGuard.

This function is suitable for capturing metrics in asynchronous code, in particular when using a single-threaded runtime. Any metrics registered prior to the returned guard will remain attached to the recorder that was present at the time of registration, and so this cannot be used to intercept existing metrics.

Additionally, local recorders can be used in a nested fashion. When setting a new default local recorder, the previous default local recorder will be captured if one was set, and will be restored when the returned guard drops. the lifetime of the returned LocalRecorderGuard.

Any metrics recorded before a guard is returned will be completely ignored. Metrics implementations should provide an initialization method that installs the recorder internally.

The function is suitable for capturing metrics in asynchronous code that uses a single threaded runtime.

If a global recorder is set, it will be restored once the guard is dropped.