|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.opentsdb.stats.StatsCollector
public abstract class StatsCollector
Receives various stats/metrics from the current process.
Instances of this class are passed around to other classes to collect their stats/metrics and do something with them (presumably send them to a client).
This class does not do any synchronization and is not thread-safe.
Constructor Summary | |
---|---|
StatsCollector(String prefix)
Constructor. |
Method Summary | |
---|---|
void |
addExtraTag(String name,
String value)
Adds a tag to all the subsequent data points recorded. |
void |
addHostTag()
Adds a host=hostname tag. |
void |
clearExtraTag(String name)
Clears a tag added using addExtraTag . |
abstract void |
emit(String datapoint)
Method to override to actually emit a data point. |
void |
record(String name,
Histogram histo,
String xtratag)
Records a number of data points from a Histogram . |
void |
record(String name,
long value)
Records a data point. |
void |
record(String name,
long value,
String xtratag)
Records a data point. |
void |
record(String name,
Number value)
Records a data point. |
void |
record(String name,
Number value,
String xtratag)
Records a data point. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StatsCollector(String prefix)
prefix
- A prefix to add to every metric name, for example
`tsd'.Method Detail |
---|
public abstract void emit(String datapoint)
datapoint
- A data point in a format suitable for a text
import.public final void record(String name, long value)
name
- The name of the metric.value
- The current value for that metric.public final void record(String name, Number value)
name
- The name of the metric.value
- The current value for that metric.public final void record(String name, Number value, String xtratag)
name
- The name of the metric.value
- The current value for that metric.xtratag
- An extra tag (name=value
) to add to those
data points (ignored if null
).
IllegalArgumentException
- if xtratag != null
and it
doesn't follow the name=value
format.public final void record(String name, Histogram histo, String xtratag)
Histogram
.
name
- The name of the metric.histo
- The histogram to collect data points from.xtratag
- An extra tag (name=value
) to add to those
data points (ignored if null
).
IllegalArgumentException
- if xtratag != null
and it
doesn't follow the name=value
format.public final void record(String name, long value, String xtratag)
name
- The name of the metric.value
- The current value for that metric.xtratag
- An extra tag (name=value
) to add to this
data point (ignored if null
).
IllegalArgumentException
- if xtratag != null
and it
doesn't follow the name=value
format.public final void addExtraTag(String name, String value)
All subsequent calls to one of the record
methods will
associate the tag given to this method with the data point.
This method can be called multiple times to associate multiple tags with all the subsequent data points.
name
- The name of the tag.value
- The value of the tag.
IllegalArgumentException
- if the name or the value are empty
or otherwise invalid.clearExtraTag(java.lang.String)
public final void addHostTag()
host=hostname
tag.
This uses InetAddress.getLocalHost()
to find the hostname of the
current host. If the hostname cannot be looked up, (unknown)
is used instead.
public final void clearExtraTag(String name)
addExtraTag
.
name
- The name of the tag to remove from the set of extra
tags.
IllegalStateException
- if there's no extra tag currently
recorded.
IllegalArgumentException
- if the given name isn't in the
set of extra tags currently recorded.addExtraTag(java.lang.String, java.lang.String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |