public class MetricUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
OS_MXBEAN_CLASSES
These are well-known implementations of
OperatingSystemMXBean. |
static String |
VALUE |
| Constructor and Description |
|---|
MetricUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addMetrics(NamedList<Object> lst,
com.codahale.metrics.Timer timer)
Adds metrics from a Timer to a NamedList, using well-known back-compat names.
|
static <T extends PlatformManagedObject> |
addMXBeanMetrics(T obj,
Class<? extends T> intf,
String prefix,
BiConsumer<String,com.codahale.metrics.Metric> consumer)
Creates a set of metrics (gauges) that correspond to available bean properties for the provided MXBean.
|
static <T extends PlatformManagedObject> |
addMXBeanMetrics(T obj,
String[] interfaces,
String prefix,
BiConsumer<String,com.codahale.metrics.Metric> consumer)
Creates a set of metrics (gauges) that correspond to available bean properties for the provided MXBean.
|
static ExecutorService |
instrumentedExecutorService(ExecutorService delegate,
com.codahale.metrics.MetricRegistry metricRegistry,
String scope)
Returns an instrumented wrapper over the given executor service.
|
static double |
nsToMs(double ns)
Converts a double representing nanoseconds to a double representing milliseconds.
|
static void |
toMaps(com.codahale.metrics.MetricRegistry registry,
List<com.codahale.metrics.MetricFilter> shouldMatchFilters,
com.codahale.metrics.MetricFilter mustMatchFilter,
boolean skipHistograms,
boolean skipAggregateValues,
boolean compact,
BiConsumer<String,Object> consumer) |
static NamedList |
toNamedList(com.codahale.metrics.MetricRegistry registry,
List<com.codahale.metrics.MetricFilter> shouldMatchFilters,
com.codahale.metrics.MetricFilter mustMatchFilter,
boolean skipHistograms,
boolean skipAggregateValues,
boolean compact,
Map<String,Object> metadata)
Returns a NamedList representation of the given metric registry.
|
public static final String VALUE
public static String[] OS_MXBEAN_CLASSES
OperatingSystemMXBean.
Some of them provide additional useful properties beyond those declared by the interface.public static void addMetrics(NamedList<Object> lst, com.codahale.metrics.Timer timer)
lst - The NamedList to add the metrics data totimer - The Timer to extract the metrics frompublic static double nsToMs(double ns)
ns - the amount of time in nanosecondspublic static NamedList toNamedList(com.codahale.metrics.MetricRegistry registry, List<com.codahale.metrics.MetricFilter> shouldMatchFilters, com.codahale.metrics.MetricFilter mustMatchFilter, boolean skipHistograms, boolean skipAggregateValues, boolean compact, Map<String,Object> metadata)
registry - the MetricRegistry to be converted to NamedListshouldMatchFilters - a list of MetricFilter instances.
A metric must match any one of the filters from this list to be
included in the outputmustMatchFilter - a MetricFilter.
A metric must match this filter to be included in the output.skipHistograms - discard any Histogram-s and histogram parts of Timer-s.compact - use compact representation for counters and gauges.metadata - optional metadata. If not null and not empty then this map will be added under a
_metadata_ key.NamedListpublic static void toMaps(com.codahale.metrics.MetricRegistry registry,
List<com.codahale.metrics.MetricFilter> shouldMatchFilters,
com.codahale.metrics.MetricFilter mustMatchFilter,
boolean skipHistograms,
boolean skipAggregateValues,
boolean compact,
BiConsumer<String,Object> consumer)
public static ExecutorService instrumentedExecutorService(ExecutorService delegate, com.codahale.metrics.MetricRegistry metricRegistry, String scope)
public static <T extends PlatformManagedObject> void addMXBeanMetrics(T obj, Class<? extends T> intf, String prefix, BiConsumer<String,com.codahale.metrics.Metric> consumer)
T - formal typeobj - an instance of MXBeanintf - MXBean interface, one of PlatformManagedObject-sconsumer - consumer for created names and metricspublic static <T extends PlatformManagedObject> void addMXBeanMetrics(T obj, String[] interfaces, String prefix, BiConsumer<String,com.codahale.metrics.Metric> consumer)
T - formal typeobj - an instance of MXBeaninterfaces - interfaces that it may implement. Each interface will be tried in turn, and only
if it exists and if it contains unique properties then they will be added as metrics.prefix - optional prefix for metric namesconsumer - consumer for created names and metricsCopyright © 2000-2017 Apache Software Foundation. All Rights Reserved.