public class StatsdMetricWriter extends Object implements MetricWriter, Closeable
MetricWriter
that pushes data to statsd. Statsd has the concept of counters
and gauges, but only supports gauges with data type Long, so values will be truncated
towards zero. Metrics whose name contains "timer." (but not "gauge." or "counter.")
will be treated as execution times (in statsd terms). Anything incremented is treated
as a counter, and anything with a snapshot value in set(Metric)
is treated as
a gauge.Constructor and Description |
---|
StatsdMetricWriter(String host,
int port)
Create a new writer instance with the given parameters.
|
StatsdMetricWriter(String prefix,
String host,
int port)
Create a new writer with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
increment(Delta<?> delta)
Increment the value of a metric (or decrement if the delta is negative).
|
void |
reset(String name)
Reset the value of a metric, usually to zero value.
|
void |
set(Metric<?> value)
Set the value of a metric.
|
public StatsdMetricWriter(String host, int port)
host
- the hostname for the statsd serverport
- the port for the statsd serverpublic void increment(Delta<?> delta)
CounterWriter
increment
in interface CounterWriter
delta
- the amount to increment bypublic void set(Metric<?> value)
GaugeWriter
set
in interface GaugeWriter
value
- the valuepublic void reset(String name)
CounterWriter
reset
in interface CounterWriter
name
- the name to resetpublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2016 Pivotal Software, Inc.. All rights reserved.