Struct dipstick::InputQueueScope
source · pub struct InputQueueScope { /* private fields */ }
Expand description
A metric scope wrapper that sends writes & flushes over a Rust sync channel. Commands are executed by a background thread.
Implementations§
source§impl InputQueueScope
impl InputQueueScope
sourcepub fn wrap<SC: InputScope + Send + Sync + 'static>(
target_scope: SC,
queue_length: usize
) -> Self
pub fn wrap<SC: InputScope + Send + Sync + 'static>(
target_scope: SC,
queue_length: usize
) -> Self
Wrap new scopes with an asynchronous metric write & flush dispatcher.
Examples found in repository?
examples/bench_queue.rs (line 13)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let bucket = AtomicBucket::new();
// NOTE: Wrapping an AtomicBucket with a Queue probably useless, as it is very fast and performs no I/O.
let queue = InputQueueScope::wrap(bucket.clone(), 10000);
let event = queue.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
.flush_to(&Stream::write_to_stdout().metrics())
.unwrap();
}
Trait Implementations§
source§impl Clone for InputQueueScope
impl Clone for InputQueueScope
source§fn clone(&self) -> InputQueueScope
fn clone(&self) -> InputQueueScope
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Flush for InputQueueScope
impl Flush for InputQueueScope
source§impl InputScope for InputQueueScope
impl InputScope for InputQueueScope
source§fn new_metric(&self, name: MetricName, kind: InputKind) -> InputMetric
fn new_metric(&self, name: MetricName, kind: InputKind) -> InputMetric
Define a generic metric of the specified type.
It is preferable to use counter() / marker() / timer() / gauge() methods.
source§impl WithAttributes for InputQueueScope
impl WithAttributes for InputQueueScope
source§fn get_attributes(&self) -> &Attributes
fn get_attributes(&self) -> &Attributes
Return attributes of component.
source§fn mut_attributes(&mut self) -> &mut Attributes
fn mut_attributes(&mut self) -> &mut Attributes
Return attributes of component for mutation.
source§fn with_attributes<F: Fn(&mut Attributes)>(&self, edit: F) -> Self
fn with_attributes<F: Fn(&mut Attributes)>(&self, edit: F) -> Self
Clone the component and mutate its attributes at once.