public final class Sensor
extends java.lang.Object
record(double)
api and would maintain a set
of metrics about request sizes such as the average or max.Modifier and Type | Class and Description |
---|---|
static class |
Sensor.RecordingLevel |
Modifier and Type | Method and Description |
---|---|
boolean |
add(CompoundStat stat)
Register a compound statistic with this sensor with no config override
|
boolean |
add(CompoundStat stat,
MetricConfig config)
Register a compound statistic with this sensor which yields multiple measurable quantities (like a histogram)
|
boolean |
add(MetricName metricName,
MeasurableStat stat)
Register a metric with this sensor
|
boolean |
add(MetricName metricName,
MeasurableStat stat,
MetricConfig config)
Register a metric with this sensor
|
void |
checkQuotas()
Check if we have violated our quota for any metric that has a configured quota
|
void |
checkQuotas(long timeMs) |
boolean |
hasExpired()
Return true if the Sensor is eligible for removal due to inactivity.
|
boolean |
hasMetrics()
Return if metrics were registered with this sensor.
|
java.lang.String |
name()
The name this sensor is registered with.
|
void |
record()
Record an occurrence, this is just short-hand for
record(1.0) |
void |
record(double value)
Record a value with this sensor
|
void |
record(double value,
long timeMs)
Record a value at a known time.
|
void |
record(double value,
long timeMs,
boolean checkQuotas)
Record a value at a known time.
|
boolean |
shouldRecord() |
java.util.List<Stat> |
stats() |
public java.lang.String name()
public boolean shouldRecord()
public void record()
record(1.0)
public void record(double value)
value
- The value to recordQuotaViolationException
- if recording this value moves a metric beyond its configured maximum or minimum
boundpublic void record(double value, long timeMs)
record(double)
since it will reuse
the time stamp.value
- The value we are recordingtimeMs
- The current POSIX time in millisecondsQuotaViolationException
- if recording this value moves a metric beyond its configured maximum or minimum
boundpublic void record(double value, long timeMs, boolean checkQuotas)
record(double)
since it will reuse
the time stamp.value
- The value we are recordingtimeMs
- The current POSIX time in millisecondscheckQuotas
- Indicate if quota must be enforced or notQuotaViolationException
- if recording this value moves a metric beyond its configured maximum or minimum
boundpublic void checkQuotas()
public void checkQuotas(long timeMs)
public boolean add(CompoundStat stat)
stat
- The stat to registerpublic boolean add(CompoundStat stat, MetricConfig config)
stat
- The stat to registerconfig
- The configuration for this stat. If null then the stat will use the default configuration for this
sensor.public boolean add(MetricName metricName, MeasurableStat stat)
metricName
- The name of the metricstat
- The statistic to keeppublic boolean add(MetricName metricName, MeasurableStat stat, MetricConfig config)
metricName
- The name of the metricstat
- The statistic to keepconfig
- A special configuration for this metric. If null use the sensor default configuration.public boolean hasMetrics()
public boolean hasExpired()
public java.util.List<Stat> stats()