Trait dipstick::CachedInput
source · pub trait CachedInput: Input + Send + Sync + 'static + Sized {
fn cached(self, max_size: usize) -> InputCache { ... }
}
Expand description
Wrap an input with a metric definition cache. This can provide performance benefits for metrics that are dynamically defined at runtime on each access. Caching is useless if all metrics are statically declared or instantiated programmatically in advance and referenced by a long living variable.
Provided Methods§
sourcefn cached(self, max_size: usize) -> InputCache
fn cached(self, max_size: usize) -> InputCache
Wrap an input with a metric definition cache. This can provide performance benefits for metrics that are dynamically defined at runtime on each access. Caching is useless if all metrics are statically declared or instantiated programmatically in advance and referenced by a long living variable.
Examples found in repository?
examples/cache.rs (line 10)
8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() {
let metrics = Stream::write_to(io::stdout())
.cached(5)
.metrics()
.named("cache");
loop {
// report some ad-hoc metric values from our "application" loop
metrics.counter("blorf").count(1134);
metrics.marker("burg").mark();
sleep(Duration::from_millis(500));
}
}