public final class MetricsSupport extends Object
Modifier | Constructor and Description |
---|---|
private |
MetricsSupport()
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
static com.codahale.metrics.MetricRegistry |
getMetricRegistry()
Get the metric registry installed into the runtime.
|
static boolean |
isMetricInstanceRegisteredUnderName(String name,
com.codahale.metrics.Metric metric,
com.codahale.metrics.MetricRegistry registry)
Determine whether the given metric instance is registered under the given name.
|
static <T extends com.codahale.metrics.Metric> |
register(String name,
T metric)
Register a metric instance under the given name.
|
static <T extends com.codahale.metrics.Metric> |
register(String name,
T metric,
boolean replaceExisting)
Register a metric instance under the given name.
|
static <T extends com.codahale.metrics.Metric> |
register(String name,
T metric,
boolean replaceExisting,
com.codahale.metrics.MetricRegistry registry)
Register a metric instance under the given name.
|
static boolean |
remove(String name)
Remove a metric instance registered under the given name.
|
static boolean |
remove(String name,
com.codahale.metrics.Metric metric)
Remove a metric instance registered under the given name.
|
static boolean |
remove(String name,
com.codahale.metrics.Metric metric,
com.codahale.metrics.MetricRegistry registry)
Remove a metric instance registered under the given name.
|
static com.codahale.metrics.Timer.Context |
startTimer(com.codahale.metrics.Timer timer)
Start the specified timer.
|
static Long |
stopTimer(com.codahale.metrics.Timer.Context context)
Stop the timer represented by the specified timer context instance.
|
@Nullable public static com.codahale.metrics.MetricRegistry getMetricRegistry()
@Nullable public static <T extends com.codahale.metrics.Metric> T register(@Nonnull String name, @Nonnull T metric)
Any existing instance registered under the given name will be replaced.
The MetricRegistry
on which to operate will be obtained via getMetricRegistry()
.
T
- the type of metric being registeredname
- the name under which to register the metricmetric
- the metric instance to register@Nullable public static <T extends com.codahale.metrics.Metric> T register(@Nonnull String name, @Nonnull T metric, boolean replaceExisting)
The MetricRegistry
on which to operate will be obtained via getMetricRegistry()
.
T
- the type of metric being registeredname
- the name under which to register the metricmetric
- the metric instance to registerreplaceExisting
- whether or not to replace the existing metric registered under that name@Nullable public static <T extends com.codahale.metrics.Metric> T register(@Nonnull String name, @Nonnull T metric, boolean replaceExisting, @Nullable com.codahale.metrics.MetricRegistry registry)
T
- the type of metric being registeredname
- the name under which to register the metricmetric
- the metric instance to registerreplaceExisting
- whether or not to replace the existing metric registered under that nameregistry
- the metric registry on which to operate.
If null, will be obtained via getMetricRegistry()
.public static boolean remove(@Nonnull String name)
name
- the name under which to deregister the metricpublic static boolean remove(@Nonnull String name, @Nullable com.codahale.metrics.Metric metric)
If a non-null metric instance is supplied, the metric instance registered under the given name will only
be removed if it is the same instance as supplied, as determined by
isMetricInstanceRegisteredUnderName(String, Metric, MetricRegistry)
The MetricRegistry
on which to operate will be obtained via getMetricRegistry()
.
name
- the name under which to deregister the metricmetric
- the metric instance to removepublic static boolean remove(@Nonnull String name, @Nullable com.codahale.metrics.Metric metric, @Nullable com.codahale.metrics.MetricRegistry registry)
If a non-null metric instance is supplied, the metric instance registered under the given name will only
be removed if it is the same instance as supplied, as determined by
isMetricInstanceRegisteredUnderName(String, Metric, MetricRegistry)
The MetricRegistry
on which to operate will be obtained via getMetricRegistry()
.
name
- the name under which to deregister the metricmetric
- the metric instance to removeregistry
- the metric registry on which to operate.
If null, will be obtained via getMetricRegistry()
.public static boolean isMetricInstanceRegisteredUnderName(@Nonnull String name, @Nonnull com.codahale.metrics.Metric metric, @Nonnull com.codahale.metrics.MetricRegistry registry)
name
- the name under which to deregister the metricmetric
- the metric instance to removeregistry
- the metric registry on which to operate.@Nullable public static com.codahale.metrics.Timer.Context startTimer(@Nullable com.codahale.metrics.Timer timer)
timer
- the timer to start, may be null@Nullable public static Long stopTimer(@Nullable com.codahale.metrics.Timer.Context context)
context
- the timer context to stop, may be nullCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.