public final class CustomMetricRegistry
extends java.lang.Object
implements java.io.Closeable, com.codahale.metrics.MetricSet
| Constructor and Description |
|---|
CustomMetricRegistry()
Creates a new
CustomMetricRegistry. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(com.codahale.metrics.MetricRegistryListener listener)
Adds a
MetricRegistryListener to a collection of listeners that will be notified on
metric creation. |
void |
close() |
com.codahale.metrics.Counter |
counter(java.lang.String name)
Return the
Counter registered under this name; or create and register
a new Counter if none is registered. |
java.util.SortedMap<java.lang.String,com.codahale.metrics.Counter> |
getCounters()
Returns a map of all the counters in the registry and their names.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Counter> |
getCounters(com.codahale.metrics.MetricFilter filter)
Returns a map of all the counters in the registry and their names which match the given
filter.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Gauge> |
getGauges()
Returns a map of all the gauges in the registry and their names.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Gauge> |
getGauges(com.codahale.metrics.MetricFilter filter)
Returns a map of all the gauges in the registry and their names which match the given filter.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Histogram> |
getHistograms()
Returns a map of all the histograms in the registry and their names.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Histogram> |
getHistograms(com.codahale.metrics.MetricFilter filter)
Returns a map of all the histograms in the registry and their names which match the given
filter.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Meter> |
getMeters()
Returns a map of all the meters in the registry and their names.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Meter> |
getMeters(com.codahale.metrics.MetricFilter filter)
Returns a map of all the meters in the registry and their names which match the given filter.
|
java.util.Map<java.lang.String,com.codahale.metrics.Metric> |
getMetrics() |
java.util.SortedSet<java.lang.String> |
getNames()
Returns a set of the names of all the metrics in the registry.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Timer> |
getTimers()
Returns a map of all the timers in the registry and their names.
|
java.util.SortedMap<java.lang.String,com.codahale.metrics.Timer> |
getTimers(com.codahale.metrics.MetricFilter filter)
Returns a map of all the timers in the registry and their names which match the given filter.
|
com.codahale.metrics.Histogram |
histogram(java.lang.String name)
Return the
Histogram registered under this name; or create and register
a new Histogram if none is registered. |
com.codahale.metrics.Meter |
meter(java.lang.String name)
|
static java.lang.String |
name(java.lang.Class<?> klass,
java.lang.String... names)
Concatenates a class name and elements to form a dotted name, eliding any null values or
empty strings.
|
static java.lang.String |
name(java.lang.String name,
java.lang.String... names)
Concatenates elements to form a dotted name, eliding any null values or empty strings.
|
<T extends com.codahale.metrics.Metric> |
register(java.lang.String name,
T metric)
Given a
Metric, registers it under the given name. |
void |
registerAll(com.codahale.metrics.MetricSet metrics)
Given a metric set, registers them.
|
boolean |
remove(java.lang.String name)
Removes the metric with the given name.
|
void |
removeListener(com.codahale.metrics.MetricRegistryListener listener)
Removes a
MetricRegistryListener from this registry's collection of listeners. |
void |
removeMatching(com.codahale.metrics.MetricFilter filter)
Removes all metrics which match the given filter.
|
com.codahale.metrics.Timer |
timer(java.lang.String name)
Return the
Timer registered under this name; or create and register
a new Timer if none is registered. |
public CustomMetricRegistry()
CustomMetricRegistry.public static java.lang.String name(java.lang.String name,
java.lang.String... names)
name - the first element of the namenames - the remaining elements of the namename and names concatenated by periodspublic static java.lang.String name(java.lang.Class<?> klass,
java.lang.String... names)
klass - the first element of the namenames - the remaining elements of the nameklass and names concatenated by periodspublic final <T extends com.codahale.metrics.Metric> T register(java.lang.String name,
T metric)
throws java.lang.IllegalArgumentException
Metric, registers it under the given name.T - the type of the metricname - the name of the metricmetric - the metricmetricjava.lang.IllegalArgumentException - if the name is already registeredpublic final void registerAll(com.codahale.metrics.MetricSet metrics)
throws java.lang.IllegalArgumentException
metrics - a set of metricsjava.lang.IllegalArgumentException - if any of the names are already registeredpublic final com.codahale.metrics.Counter counter(java.lang.String name)
Counter registered under this name; or create and register
a new Counter if none is registered.name - the name of the metricCounterpublic final com.codahale.metrics.Histogram histogram(java.lang.String name)
Histogram registered under this name; or create and register
a new Histogram if none is registered.name - the name of the metricHistogrampublic final com.codahale.metrics.Meter meter(java.lang.String name)
Meter registered under this name; or create and register
a new Meter if none is registered.name - the name of the metricMeterpublic final com.codahale.metrics.Timer timer(java.lang.String name)
Timer registered under this name; or create and register
a new Timer if none is registered.name - the name of the metricTimerpublic final boolean remove(java.lang.String name)
name - the name of the metricpublic final void removeMatching(com.codahale.metrics.MetricFilter filter)
filter - a filterpublic final void addListener(com.codahale.metrics.MetricRegistryListener listener)
MetricRegistryListener to a collection of listeners that will be notified on
metric creation. Listeners will be notified in the order in which they are added.
N.B.: The listener will be notified of all existing metrics when it first registers.
listener - the listener that will be notifiedpublic final void removeListener(com.codahale.metrics.MetricRegistryListener listener)
MetricRegistryListener from this registry's collection of listeners.listener - the listener that will be removedpublic final java.util.SortedSet<java.lang.String> getNames()
public final java.util.SortedMap<java.lang.String,com.codahale.metrics.Gauge> getGauges()
public final java.util.SortedMap<java.lang.String,com.codahale.metrics.Gauge> getGauges(com.codahale.metrics.MetricFilter filter)
filter - the metric filter to matchpublic final java.util.SortedMap<java.lang.String,com.codahale.metrics.Counter> getCounters()
public final java.util.SortedMap<java.lang.String,com.codahale.metrics.Counter> getCounters(com.codahale.metrics.MetricFilter filter)
filter - the metric filter to matchpublic final java.util.SortedMap<java.lang.String,com.codahale.metrics.Histogram> getHistograms()
public final java.util.SortedMap<java.lang.String,com.codahale.metrics.Histogram> getHistograms(com.codahale.metrics.MetricFilter filter)
filter - the metric filter to matchpublic final java.util.SortedMap<java.lang.String,com.codahale.metrics.Meter> getMeters()
public final java.util.SortedMap<java.lang.String,com.codahale.metrics.Meter> getMeters(com.codahale.metrics.MetricFilter filter)
filter - the metric filter to matchpublic final java.util.SortedMap<java.lang.String,com.codahale.metrics.Timer> getTimers()
public final java.util.SortedMap<java.lang.String,com.codahale.metrics.Timer> getTimers(com.codahale.metrics.MetricFilter filter)
filter - the metric filter to matchpublic final java.util.Map<java.lang.String,com.codahale.metrics.Metric> getMetrics()
getMetrics in interface com.codahale.metrics.MetricSetpublic final void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException