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>| 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.
|
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.
|
getConfiguration, getJavaSystemProperties, getOSEnvpublic MetricsInstrumentation()
public void addCron(String group, String name, Instrumentation.Cron cron)
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)
Gauge.addVariable in class Instrumentationgroup - counter group.name - counter name.variable - variable to add.public void incr(String group, String name, long count)
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)
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 toIOExceptionpublic 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 © 2015 Apache Software Foundation. All Rights Reserved.