Struct dipstick::Statsd

source ·
pub struct Statsd { /* private fields */ }
Expand description

Statsd Input holds a datagram (UDP) socket to a statsd server. The socket is shared between scopes opened from the Input.

Implementations§

Send metrics to a statsd server at the address and port provided.

Examples found in repository?
examples/statsd_sampling.rs (line 7)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let metrics = Statsd::send_to("localhost:8125")
        .expect("Connected")
        .sampled(Sampling::Random(0.2))
        .named("my_app")
        .metrics();

    let counter = metrics.counter("counter_a");

    loop {
        for i in 1..11 {
            counter.count(i);
        }
        std::thread::sleep(Duration::from_millis(3000));
    }
}
More examples
Hide additional examples
examples/statsd_nosampling.rs (line 7)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let metrics = Statsd::send_to("localhost:8125")
        .expect("Connected")
        //            .with_sampling(Sampling::Random(0.2))
        .named("my_app")
        .metrics();

    let counter = metrics.counter("counter_a");

    loop {
        for i in 1..11 as usize {
            counter.count(i);
        }
        std::thread::sleep(Duration::from_millis(3000));
    }
}
examples/per_metric_sampling.rs (line 7)
6
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
36
fn main() {
    let statsd = Statsd::send_to("localhost:8125")
        .expect("Connected")
        .named("my_app");
    // Sampling::Full is the default
    // .sampled(Sampling::Full);

    let unsampled_marker = statsd.metrics().marker("marker_a");

    let low_freq_marker = statsd
        .sampled(Sampling::Random(0.1))
        .metrics()
        .marker("low_freq_marker");

    let hi_freq_marker = statsd
        .sampled(Sampling::Random(0.001))
        .metrics()
        .marker("hi_freq_marker");

    loop {
        unsampled_marker.mark();

        for _i in 0..10 {
            low_freq_marker.mark();
        }
        for _i in 0..1000 {
            hi_freq_marker.mark();
        }
        std::thread::sleep(Duration::from_millis(3000));
    }
}

Trait Implementations§

Return a clone with the specified buffering set.
Return the current buffering strategy.
Returns false if the current buffering strategy is Buffering::Unbuffered. Returns true otherwise.
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.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The type of Scope returned byt this input.
Open a new scope from this input.
👎Deprecated since 0.7.2: Use metrics()
Open a new scope from this input.
👎Deprecated since 0.8.0: Use metrics()
Open a new scope from this input.
Wrap this output with an asynchronous dispatch queue of specified length.
Perform random sampling of values according to the specified rate.
Get the sampling strategy for this component, if any.
Return attributes of component.
Return attributes of component for mutation.
Clone the component and mutate its attributes at once.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.