public class MetricsInstrumentation extends Instrumentation
Instrumentation but is backed by Codahale Metrics. This class
was designed to minimize the changes required to switch from Instrumentation to MetricsInstrumentation by keeping
the same API. However, certain operations are obviously implemented differently or are no longer needed; and the output format
is a little different. Internally, this class maps Cron to Timer, Variable to Gauge,
counter to Counter, and Sampler to Histogram.| Modifier and Type | Class and Description |
|---|---|
static class |
MetricsInstrumentation.Sampler |
Instrumentation.Cron, Instrumentation.Element<T>, Instrumentation.Timer, Instrumentation.Variable<T>| Modifier and Type | Field and Description |
|---|---|
static String |
EXTERNAL_MONITORING_ADDRESS |
static String |
EXTERNAL_MONITORING_ENABLE |
static String |
EXTERNAL_MONITORING_INTERVAL |
static String |
EXTERNAL_MONITORING_PREFIX |
static String |
EXTERNAL_MONITORING_TYPE |
static String |
GANGLIA |
static String |
GRAPHITE |
static String |
JMX_MONITORING_ENABLE |
protected XLog |
LOG |
| Constructor and Description |
|---|
MetricsInstrumentation()
Creates the MetricsInstrumentation and starts taking some metrics.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCron(String group,
String name,
Instrumentation.Cron cron)
Add a cron to an instrumentation timer.
|
void |
addSampler(String group,
String name,
int period,
int interval,
Instrumentation.Variable<Long> variable)
Add a sampling variable.
|
void |
addVariable(String group,
String name,
Instrumentation.Variable variable)
Add an instrumentation variable.
|
Map<String,Map<String,Map<String,Object>>> |
getAll()
Not Supported: throws
UnsupportedOperationException |
Map<String,Map<String,Instrumentation.Element<Long>>> |
getCounters()
Not Supported: throws
UnsupportedOperationException |
Map<String,Map<String,Instrumentation.Element<Double>>> |
getSamplers()
Not Supported: throws
UnsupportedOperationException |
Map<String,Map<String,Instrumentation.Element<Instrumentation.Timer>>> |
getTimers()
Not Supported: throws
UnsupportedOperationException |
Map<String,Map<String,Instrumentation.Element<Instrumentation.Variable>>> |
getVariables()
Not Supported: throws
UnsupportedOperationException |
void |
incr(String group,
String name,
long count)
Increment an instrumentation counter.
|
void |
setScheduler(ScheduledExecutorService scheduler)
Set the scheduler instance to handle the samplers.
|
void |
stop()
Reporting final metrics into the server before stopping
|
String |
toString()
Return the string representation of the instrumentation.
|
void |
writeJSONResponse(OutputStream os)
Converts the current state of the metrics and writes them to the OutputStream.
|
decr, getConfiguration, getJavaSystemProperties, getOSEnvpublic static final String EXTERNAL_MONITORING_ENABLE
public static final String EXTERNAL_MONITORING_TYPE
public static final String EXTERNAL_MONITORING_ADDRESS
public static final String EXTERNAL_MONITORING_PREFIX
public static final String EXTERNAL_MONITORING_INTERVAL
public static final String JMX_MONITORING_ENABLE
public static final String GRAPHITE
public static final String GANGLIA
public MetricsInstrumentation()
public void stop()
stop in class Instrumentationpublic void addCron(String group, String name, Instrumentation.Cron cron)
Internally, this is backed by a Timer.
addCron in class Instrumentationgroup - timer group.name - timer name.cron - cron to add to the timer.public void addVariable(String group, String name, Instrumentation.Variable variable)
Internally, this is backed by a Gauge.
addVariable in class Instrumentationgroup - counter group.name - counter name.variable - variable to add.public void incr(String group, String name, long count)
Internally, this is backed by a Counter.
incr in class Instrumentationgroup - counter group.name - counter name.count - increment to add to the counter.public void addSampler(String group, String name, int period, int interval, Instrumentation.Variable<Long> variable)
Internally, this is backed by a biased (decaying) Histogram.
addSampler in class Instrumentationgroup - timer group.name - timer name.period - (ignored)interval - sampling frequency, how often the variable is probed.variable - variable to sample.public void setScheduler(ScheduledExecutorService scheduler)
setScheduler in class Instrumentationscheduler - scheduler instance.public String toString()
toString in class Instrumentationpublic void writeJSONResponse(OutputStream os) throws IOException
os - The OutputStream to write the metrics toIOException - in case of error during writing to the streampublic Map<String,Map<String,Map<String,Object>>> getAll()
UnsupportedOperationExceptiongetAll in class Instrumentationpublic Map<String,Map<String,Instrumentation.Element<Long>>> getCounters()
UnsupportedOperationExceptiongetCounters in class Instrumentationpublic Map<String,Map<String,Instrumentation.Element<Double>>> getSamplers()
UnsupportedOperationExceptiongetSamplers in class Instrumentationpublic Map<String,Map<String,Instrumentation.Element<Instrumentation.Timer>>> getTimers()
UnsupportedOperationExceptiongetTimers in class Instrumentationpublic Map<String,Map<String,Instrumentation.Element<Instrumentation.Variable>>> getVariables()
UnsupportedOperationExceptiongetVariables in class InstrumentationCopyright © 2018 Apache Software Foundation. All rights reserved.