Class ActivityMetrics
public class ActivityMetrics
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_HDRDIGITSstatic java.lang.StringHDRDIGITS_PARAMstatic com.codahale.metrics.MetricFilterMETRIC_FILTER -
Method Summary
Modifier and Type Method Description static voidaddClassicHistos(java.lang.String sessionName, java.lang.String pattern, java.lang.String prefix, java.lang.String interval)Add a classic histogram in addition to the default implementation in this runtime.static voidaddHistoLogger(java.lang.String sessionName, java.lang.String pattern, java.lang.String filename, java.lang.String interval)Add a histogram interval logger to matching metrics in this JVM instance.static voidaddStatsLogger(java.lang.String sessionName, java.lang.String pattern, java.lang.String filename, java.lang.String interval)Add a histogram stats logger to matching metrics in this JVM instance.static voidcloseMetrics(boolean showChart)This should be called at the end of a process, so that open intervals can be finished, logs closed properly, etc.static com.codahale.metrics.Countercounter(ActivityDef activityDef, java.lang.String name)Create a counter associated with an activity.static <T> com.codahale.metrics.Gauge<T>gauge(ActivityDef activityDef, java.lang.String name, com.codahale.metrics.Gauge<T> gauge)static <T> com.codahale.metrics.Gauge<T>gauge(javax.script.ScriptContext scriptContext, java.lang.String name, com.codahale.metrics.Gauge<T> gauge)static intgetHdrDigits()static com.codahale.metrics.MetricRegistrygetMetricRegistry()static com.codahale.metrics.Histogramhistogram(ActivityDef activityDef, java.lang.String name)Create an HDR histogram associated with an activity.static com.codahale.metrics.Metermeter(ActivityDef activityDef, java.lang.String name)Create a meter associated with an activity.static voidmountSubRegistry(java.lang.String mountPrefix, com.codahale.metrics.MetricRegistry subRegistry)static voidremoveActivityMetrics(ActivityDef activityDef)static voidreportTo(java.io.PrintStream out)static voidsetHdrDigits(int hdrDigits)static com.codahale.metrics.Timertimer(ActivityDef activityDef, java.lang.String name)Create a timer associated with an activity.
-
Field Details
-
HDRDIGITS_PARAM
public static final java.lang.String HDRDIGITS_PARAM- See Also:
- Constant Field Values
-
DEFAULT_HDRDIGITS
public static final int DEFAULT_HDRDIGITS- See Also:
- Constant Field Values
-
METRIC_FILTER
public static com.codahale.metrics.MetricFilter METRIC_FILTER
-
-
Method Details
-
getHdrDigits
public static int getHdrDigits() -
setHdrDigits
public static void setHdrDigits(int hdrDigits) -
timer
Create a timer associated with an activity.
If the provide ActivityDef contains a parameter "hdr_digits", then it will be used to set the number of significant digits on the histogram's precision.
This method ensures that if multiple threads attempt to create the same-named metric on a given activity, that only one of them succeeds.
- Parameters:
activityDef- an associated activity defname- a simple, descriptive name for the timer- Returns:
- the timer, perhaps a different one if it has already been registered
-
histogram
public static com.codahale.metrics.Histogram histogram(ActivityDef activityDef, java.lang.String name)Create an HDR histogram associated with an activity.
If the provide ActivityDef contains a parameter "hdr_digits", then it will be used to set the number of significant digits on the histogram's precision.
This method ensures that if multiple threads attempt to create the same-named metric on a given activity, that only one of them succeeds.
- Parameters:
activityDef- an associated activity defname- a simple, descriptive name for the histogram- Returns:
- the histogram, perhaps a different one if it has already been registered
-
counter
Create a counter associated with an activity.
This method ensures that if multiple threads attempt to create the same-named metric on a given activity, that only one of them succeeds.
- Parameters:
activityDef- an associated activity defname- a simple, descriptive name for the counter- Returns:
- the counter, perhaps a different one if it has already been registered
-
meter
Create a meter associated with an activity.
This method ensures that if multiple threads attempt to create the same-named metric on a given activity, that only one of them succeeds.
- Parameters:
activityDef- an associated activity defname- a simple, descriptive name for the meter- Returns:
- the meter, perhaps a different one if it has already been registered
-
gauge
public static <T> com.codahale.metrics.Gauge<T> gauge(ActivityDef activityDef, java.lang.String name, com.codahale.metrics.Gauge<T> gauge) -
gauge
public static <T> com.codahale.metrics.Gauge<T> gauge(javax.script.ScriptContext scriptContext, java.lang.String name, com.codahale.metrics.Gauge<T> gauge) -
getMetricRegistry
public static com.codahale.metrics.MetricRegistry getMetricRegistry() -
addHistoLogger
public static void addHistoLogger(java.lang.String sessionName, java.lang.String pattern, java.lang.String filename, java.lang.String interval)Add a histogram interval logger to matching metrics in this JVM instance.- Parameters:
sessionName- The name for the session to be annotated in the histogram logpattern- A regular expression pattern to filter out metric names for loggingfilename- A file to log the histogram data ininterval- How many seconds to wait between writing each interval histogram
-
addStatsLogger
public static void addStatsLogger(java.lang.String sessionName, java.lang.String pattern, java.lang.String filename, java.lang.String interval)Add a histogram stats logger to matching metrics in this JVM instance.- Parameters:
sessionName- The name for the session to be annotated in the histogram logpattern- A regular expression pattern to filter out metric names for loggingfilename- A file to log the histogram data ininterval- How many seconds to wait between writing each interval histogram
-
addClassicHistos
public static void addClassicHistos(java.lang.String sessionName, java.lang.String pattern, java.lang.String prefix, java.lang.String interval)Add a classic histogram in addition to the default implementation in this runtime. This is a way to get a view to both the enhanced histogram implementation as well as the classic implementation in the same scenario.- Parameters:
sessionName- The name of the session to be annotated in the classic histogrampattern- A regular expression pattern to filter out metric names for inclusionprefix- The name prefix to add to the classic histograms so that they fit into the existing metrics namespaceinterval- How frequently to update the histogram
-
closeMetrics
public static void closeMetrics(boolean showChart)This should be called at the end of a process, so that open intervals can be finished, logs closed properly, etc.- Parameters:
showChart- whether to chart metrics on console
-
reportTo
public static void reportTo(java.io.PrintStream out) -
mountSubRegistry
public static void mountSubRegistry(java.lang.String mountPrefix, com.codahale.metrics.MetricRegistry subRegistry) -
removeActivityMetrics
-