pub struct Graphite { /* private fields */ }
Expand description
Graphite Input holds a socket to a graphite server. The socket is shared between scopes opened from the Input.
Implementations§
source§impl Graphite
impl Graphite
sourcepub fn send_to<A: ToSocketAddrs + Debug + Clone>(address: A) -> Result<Graphite>
pub fn send_to<A: ToSocketAddrs + Debug + Clone>(address: A) -> Result<Graphite>
Send metrics to a graphite server at the address and port provided.
Examples found in repository?
examples/graphite.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
let metrics = Graphite::send_to("localhost:2003")
.expect("Connected")
.named("my_app")
.metrics();
loop {
metrics.counter("counter_a").count(123);
metrics.timer("timer_a").interval_us(2000000);
std::thread::sleep(Duration::from_millis(40));
}
}
More examples
examples/multi_input.rs (line 9)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() {
// will output metrics to graphite and to stdout
let different_type_metrics = MultiInput::new()
.add_target(Graphite::send_to("localhost:2003").expect("Connecting"))
.add_target(Stream::write_to_stdout())
.metrics();
// will output metrics twice, once with "both.yeah" prefix and once with "both.ouch" prefix.
let same_type_metrics = MultiInput::new()
.add_target(Stream::write_to_stderr().named("yeah"))
.add_target(Stream::write_to_stderr().named("ouch"))
.named("both")
.metrics();
loop {
different_type_metrics.counter("counter_a").count(123);
same_type_metrics.timer("timer_a").interval_us(2000000);
std::thread::sleep(Duration::from_millis(400));
}
}
examples/bucket2graphite.rs (line 14)
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 37 38 39 40 41 42 43
fn main() {
// adding a name to the stats
let bucket = AtomicBucket::new().named("test");
// adding two names to Graphite output
// metrics will be prefixed with "machine1.application.test"
bucket.drain(
Graphite::send_to("localhost:2003")
.expect("Socket")
.named("machine1")
.add_name("application"),
);
bucket.flush_every(Duration::from_secs(3));
let counter = bucket.counter("counter_a");
let timer = bucket.timer("timer_a");
let gauge = bucket.gauge("gauge_a");
let marker = bucket.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();
}
}
Trait Implementations§
source§impl Buffered for Graphite
impl Buffered for Graphite
source§fn buffered(&self, buffering: Buffering) -> Self
fn buffered(&self, buffering: Buffering) -> Self
Return a clone with the specified buffering set.
source§fn get_buffering(&self) -> Buffering
fn get_buffering(&self) -> Buffering
Return the current buffering strategy.
source§fn is_buffered(&self) -> bool
fn is_buffered(&self) -> bool
Returns false if the current buffering strategy is
Buffering::Unbuffered
.
Returns true otherwise.source§impl CachedInput for Graphite
impl CachedInput for Graphite
source§fn cached(self, max_size: usize) -> InputCache
fn cached(self, max_size: usize) -> InputCache
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.
source§impl Input for Graphite
impl Input for Graphite
source§impl QueuedInput for Graphite
impl QueuedInput for Graphite
source§fn queued(self, max_size: usize) -> InputQueue
fn queued(self, max_size: usize) -> InputQueue
Wrap this output with an asynchronous dispatch queue of specified length.
source§impl WithAttributes for Graphite
impl WithAttributes for Graphite
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 Graphite
impl !RefUnwindSafe for Graphite
impl Send for Graphite
impl Sync for Graphite
impl Unpin for Graphite
impl !UnwindSafe for Graphite
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> 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.