public final class NoopRegistry extends Object implements Registry
| Constructor and Description |
|---|
NoopRegistry() |
| Modifier and Type | Method and Description |
|---|---|
Clock |
clock()
The clock used by the registry for timing events.
|
Counter |
counter(Id id)
Measures the rate of some activity.
|
Stream<Counter> |
counters()
Returns a stream of all registered counters.
|
Id |
createId(String name)
Creates an identifier for a meter.
|
Id |
createId(String name,
Iterable<Tag> tags)
Creates an identifier for a meter.
|
Id |
createId(String name,
Map<String,String> tags)
Creates an identifier for a meter.
|
Id |
createId(String name,
String... tags)
Creates an identifier for a meter.
|
Stream<DistributionSummary> |
distributionSummaries()
Returns a stream of all registered distribution summaries.
|
DistributionSummary |
distributionSummary(Id id)
Measures the rate and variation in amount for some activity.
|
Gauge |
gauge(Id id)
Represents a value sampled from another source.
|
Stream<Gauge> |
gauges()
Returns a stream of all registered gauges.
|
Meter |
get(Id id)
Returns the meter associated with a given id.
|
Iterator<Meter> |
iterator()
Iterator for traversing the set of meters in the registry.
|
Gauge |
maxGauge(Id id)
Measures the maximum value recorded since the last reset.
|
Stream<Measurement> |
measurements()
Returns a stream with the current flattened set of measurements across all meters.
|
void |
propagate(String msg,
Throwable t)
Log a warning and if enabled propagate the exception
t. |
void |
propagate(Throwable t)
Log a warning using the message from the exception and if enabled propagate the
exception
t. |
void |
register(Meter meter)
Deprecated.
|
Spliterator<Meter> |
spliterator() |
ConcurrentMap<Id,Object> |
state()
Returns a map that can be used to associate state with the registry.
|
Stream<Meter> |
stream()
Returns a stream of all registered meters.
|
Timer |
timer(Id id)
Measures the rate and time taken for short running tasks.
|
Stream<Timer> |
timers()
Returns a stream of all registered timers.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcollectionSize, collectionSize, config, counter, counter, counter, distributionSummary, distributionSummary, distributionSummary, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, longTaskTimer, longTaskTimer, longTaskTimer, longTaskTimer, mapSize, mapSize, maxGauge, maxGauge, maxGauge, methodValue, methodValue, timer, timer, timer, underlyingpublic Clock clock()
Registrypublic Id createId(String name)
Registrypublic Id createId(String name, Iterable<Tag> tags)
Registrypublic Id createId(String name, String... tags)
Registrypublic Id createId(String name, Map<String,String> tags)
Registry@Deprecated public void register(Meter meter)
Registryregister in interface RegistryRegistry.gauge(Id, Number),
Registry.gauge(Id, Object, ToDoubleFunction),
Registry.collectionSize(Id, Collection),
Registry.mapSize(Id, Map)public ConcurrentMap<Id,Object> state()
RegistryLongTaskTimer.public Counter counter(Id id)
Registrycounter in interface Registryid - Identifier created by a call to Registry.createId(java.lang.String)public DistributionSummary distributionSummary(Id id)
RegistrydistributionSummary in interface Registryid - Identifier created by a call to Registry.createId(java.lang.String)public Timer timer(Id id)
Registrytimer in interface Registryid - Identifier created by a call to Registry.createId(java.lang.String)public Gauge gauge(Id id)
RegistryGauge.set(double).
Registry implementations are free to expire the gauge if it has not been updated in the
last minute. If you do not want to worry about the sampling, then use PolledMeter
instead.gauge in interface Registryid - Identifier created by a call to Registry.createId(java.lang.String)public Gauge maxGauge(Id id)
RegistryRegistry.distributionSummary(Id) which provides a max along with other stats for most
registry implementations.maxGauge in interface Registryid - Identifier created by a call to Registry.createId(java.lang.String)public Meter get(Id id)
Registrypublic Iterator<Meter> iterator()
Registrypublic Spliterator<Meter> spliterator()
spliterator in interface Iterable<Meter>public Stream<Measurement> measurements()
RegistryRegistry.stream() to get the data as it will
automatically handle expired meters, NaN values, etc.measurements in interface Registrypublic Stream<Meter> stream()
Registrypublic Stream<Counter> counters()
Registry
LongSummaryStatistics summary = r.counters()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingLong(Counter::count));
public Stream<DistributionSummary> distributionSummaries()
Registry
LongSummaryStatistics countSummary = r.distributionSummaries()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingLong(DistributionSummary::count));
LongSummaryStatistics totalSummary = r.distributionSummaries()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingLong(DistributionSummary::totalAmount));
double avgAmount = (double) totalSummary.getSum() / countSummary.getSum();
distributionSummaries in interface Registrypublic Stream<Timer> timers()
Registry
LongSummaryStatistics countSummary = r.timers()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingLong(Timer::count));
LongSummaryStatistics totalSummary = r.timers()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingLong(Timer::totalTime));
double avgTime = (double) totalSummary.getSum() / countSummary.getSum();
public Stream<Gauge> gauges()
Registry
DoubleSummaryStatistics valueSummary = r.gauges()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingDouble(Gauge::value));
double sum = (double) valueSummary.getSum();
public void propagate(String msg, Throwable t)
Registryt. As a general rule
instrumentation code should degrade gracefully and avoid impacting the core application. If
the user makes a mistake and causes something to break, then it should not impact the
application unless that mistake triggers a problem outside of the instrumentation code.
However, in test code it is often better to throw so that mistakes are caught and corrected.
This method is used to handle exceptions internal to the instrumentation code. Propagation
is controlled by the RegistryConfig.propagateWarnings() setting. If the setting
is true, then the exception will be propagated. Otherwise the exception will only get logged
as a warning.public void propagate(Throwable t)
Registryt. For more information see Registry.propagate(String, Throwable).