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)
10fn main() {
11 let bucket = AtomicBucket::new();
12 // NOTE: Wrapping an AtomicBucket with a Queue probably useless, as it is very fast and performs no I/O.
13 let queue = InputQueueScope::wrap(bucket.clone(), 10000);
14 let event = queue.marker("a");
15 let args = &mut args();
16 args.next();
17 let tc: u8 = u8::from_str(&args.next().unwrap()).unwrap();
18 for _ in 0..tc {
19 let event = event.clone();
20 thread::spawn(move || {
21 loop {
22 // report some metric values from our "application" loop
23 event.mark();
24 }
25 });
26 }
27 sleep(Duration::from_secs(5));
28 bucket
29 .flush_to(&Stream::write_to_stdout().metrics())
30 .unwrap();
31}
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.
Auto Trait Implementations§
impl Freeze for InputQueueScope
impl !RefUnwindSafe for InputQueueScope
impl Send for InputQueueScope
impl Sync for InputQueueScope
impl Unpin for InputQueueScope
impl !UnwindSafe for InputQueueScope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Observe for Twhere
T: InputScope + WithAttributes,
impl<T> Observe for Twhere
T: InputScope + WithAttributes,
Source§impl<T> OnFlush for Twhere
T: Flush + WithAttributes,
impl<T> OnFlush for Twhere
T: Flush + WithAttributes,
Source§fn notify_flush_listeners(&self)
fn notify_flush_listeners(&self)
Notify registered listeners of an impending flush.
Source§impl<T> Prefixed for Twhere
T: WithAttributes,
impl<T> Prefixed for Twhere
T: WithAttributes,
Source§fn get_prefixes(&self) -> &NameParts
fn get_prefixes(&self) -> &NameParts
Returns namespace of component.
Source§fn add_prefix<S>(&self, name: S) -> T
👎Deprecated since 0.7.2: Use named() or add_name()
fn add_prefix<S>(&self, name: S) -> T
Append a name to the existing names. Return a clone of the component with the updated names.
Source§fn add_name<S>(&self, name: S) -> T
fn add_name<S>(&self, name: S) -> T
Append a name to the existing names. Return a clone of the component with the updated names.
Source§fn named<S>(&self, name: S) -> T
fn named<S>(&self, name: S) -> T
Replace any existing names with a single name.
Return a clone of the component with the new name.
If multiple names are required, add_name
may also be used.
Source§fn prefix_append<S: Into<MetricName>>(&self, name: S) -> MetricName
fn prefix_append<S: Into<MetricName>>(&self, name: S) -> MetricName
Append any name parts to the name’s namespace.
Source§fn prefix_prepend<S: Into<MetricName>>(&self, name: S) -> MetricName
fn prefix_prepend<S: Into<MetricName>>(&self, name: S) -> MetricName
Prepend any name parts to the name’s namespace.
Source§impl<T> ScheduleFlush for T
impl<T> ScheduleFlush for T
Source§fn flush_every(&self, period: Duration) -> CancelHandle
fn flush_every(&self, period: Duration) -> CancelHandle
Flush this scope at regular intervals.