Struct 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

Source

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

Source§

fn clone(&self) -> InputQueueScope

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Flush for InputQueueScope

Source§

fn flush(&self) -> Result<()>

Flush does nothing by default.
Source§

impl InputScope for InputQueueScope

Source§

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§

fn counter(&self, name: &str) -> Counter

Define a Counter.
Source§

fn marker(&self, name: &str) -> Marker

Define a Marker.
Source§

fn timer(&self, name: &str) -> Timer

Define a Timer.
Source§

fn gauge(&self, name: &str) -> Gauge

Define a Gauge.
Source§

fn level(&self, name: &str) -> Level

Define a Level.
Source§

impl WithAttributes for InputQueueScope

Source§

fn get_attributes(&self) -> &Attributes

Return attributes of component.
Source§

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

Clone the component and mutate its attributes at once.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Observe for T

Source§

type Inner = T

The inner type for the ObserveWhen. Read more
Source§

fn observe<F>( &self, metric: impl Deref<Target = InputMetric>, operation: F, ) -> ObserveWhen<'_, T, F>
where F: Fn(Instant) -> isize + Send + Sync + 'static,

Provide a source for a metric’s values.
Source§

impl<T> OnFlush for T
where T: Flush + WithAttributes,

Source§

fn notify_flush_listeners(&self)

Notify registered listeners of an impending flush.
Source§

impl<T> Prefixed for T
where T: WithAttributes,

Source§

fn get_prefixes(&self) -> &NameParts

Returns namespace of component.

Source§

fn add_prefix<S>(&self, name: S) -> T
where S: Into<String>,

👎Deprecated since 0.7.2: Use named() or add_name()

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
where S: Into<String>,

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
where S: Into<String>,

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

Append any name parts to the name’s namespace.
Source§

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
where T: InputScope + Send + Sync + Clone + 'static,

Source§

fn flush_every(&self, period: Duration) -> CancelHandle

Flush this scope at regular intervals.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.