Skip to main content

with_capturing_test_client_async

Function with_capturing_test_client_async 

Source
pub async fn with_capturing_test_client_async(
    future: impl Future<Output = ()>,
) -> Vec<String>
Expand description

Awaits future with a thread-local mock recorder installed, then returns all captured metrics as "name:value|type|#key:value,key:value" strings.

The recorder stays installed across await points, so metrics emitted while the future is suspended are captured as well. Since it is thread-local, the future must not migrate between threads: run it on a current-thread runtime, as #[tokio::test] does by default.

§Example

let captured = objectstore_metrics::with_capturing_test_client_async(async {
    objectstore_metrics::count!("test.counter");
})
.await;
assert!(captured.iter().any(|m| m.starts_with("test.counter:")));