1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Per-call telemetry for plugins.
//!
//! Every plugin generated by `plugin!` embeds a metric recorder that can record
//! wall-clock durations for sync and async call. Recording is disabled by default,
//! but can be enabled at runtime through the [`Metrics`] trait.
//!
//! Internally each function slot maps to a fixed-size ring buffer that
//! stores the last durations without heap allocation on the hot path.
//!
//! # Usage
//!
//! ```
//! # use interoptopus::plugin;
//! # use crate::interoptopus::telemetry::Metrics;
//! // Define a plugin
//! plugin!(MyService {
//! fn foo();
//! });
//!
//! # fn f(plugin: &MyService) {
//! // Enable recording
//! plugin.metrics_enable(true);
//!
//! // Call plugin
//! plugin.foo();
//!
//! // Retrieve report
//! let report = plugin.metrics_report();
//! # }
//! ```
const MAX_RECORDED_DURATIONS: usize = 16 * 1024;
pub use MetricsRecorder;
pub use ;
/// A trait for things that can record performance metrics.