pub struct Marker { /* private fields */ }
Expand description
A monotonic counter metric. Since value is only ever increased by one, no value parameter is provided, preventing programming errors.
Implementations§
source§impl Marker
impl Marker
sourcepub fn mark(&self)
pub fn mark(&self)
Record a single event occurence.
Examples found in repository?
examples/buffered_flush_on_drop.rs (line 16)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let input = Stream::write_to_stdout().buffered(Buffering::Unlimited);
loop {
println!("\n------- open scope");
let metrics = input.metrics();
metrics.marker("marker_a").mark();
sleep(Duration::from_millis(1000));
println!("------- close scope: ");
}
}
More examples
examples/cache.rs (line 17)
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));
}
}
examples/bucket_cleanup.rs (line 20)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let bucket = AtomicBucket::new();
AtomicBucket::default_drain(Stream::write_to_stdout());
let persistent_marker = bucket.marker("persistent");
let mut i = 0;
loop {
i += 1;
let transient_marker = bucket.marker(&format!("marker_{}", i));
transient_marker.mark();
persistent_marker.mark();
bucket.flush().unwrap();
sleep(Duration::from_secs(1));
}
}
examples/bench_bucket.rs (line 21)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let bucket = AtomicBucket::new();
let event = bucket.marker("a");
let args = &mut args();
args.next();
let tc: u8 = u8::from_str(&args.next().unwrap()).unwrap();
for _ in 0..tc {
let event = event.clone();
thread::spawn(move || {
loop {
// report some metric values from our "application" loop
event.mark();
}
});
}
sleep(Duration::from_secs(5));
bucket.stats(stats_all);
bucket
.flush_to(&Stream::write_to_stdout().metrics())
.unwrap();
}
examples/bench_bucket_proxy.rs (line 25)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let event = Proxy::default().marker("a");
let bucket = AtomicBucket::new();
Proxy::default().target(bucket.clone());
let args = &mut args();
args.next();
let tc: u8 = u8::from_str(&args.next().unwrap()).unwrap();
for _ in 0..tc {
let event = event.clone();
thread::spawn(move || {
loop {
// report some metric values from our "application" loop
event.mark();
}
});
}
sleep(Duration::from_secs(5));
bucket
.flush_to(&Stream::write_to_stdout().metrics())
.unwrap();
}
examples/bucket2stdout.rs (line 33)
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
fn main() {
let metrics = AtomicBucket::new().named("test");
metrics.drain(Stream::write_to_stdout());
metrics.flush_every(Duration::from_secs(3));
let counter = metrics.counter("counter_a");
let timer = metrics.timer("timer_a");
let gauge = metrics.gauge("gauge_a");
let marker = metrics.marker("marker_a");
loop {
// add counts forever, non-stop
counter.count(11);
counter.count(12);
counter.count(13);
timer.interval_us(11_000_000);
timer.interval_us(12_000_000);
timer.interval_us(13_000_000);
gauge.value(11);
gauge.value(12);
gauge.value(13);
marker.mark();
}
}
Additional examples can be found in:
Methods from Deref<Target = InputMetric>§
sourcepub fn write(&self, value: MetricValue, labels: Labels)
pub fn write(&self, value: MetricValue, labels: Labels)
Collect a new value for this metric.
Trait Implementations§
source§impl From<InputMetric> for Marker
impl From<InputMetric> for Marker
source§fn from(metric: InputMetric) -> Marker
fn from(metric: InputMetric) -> Marker
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Marker
impl !RefUnwindSafe for Marker
impl Send for Marker
impl Sync for Marker
impl Unpin for Marker
impl !UnwindSafe for Marker
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more