public interface Registry extends Iterable<Meter>
Modifier and Type | Method and Description |
---|---|
Clock |
clock()
The clock used by the registry for timing events.
|
default <T extends Collection<?>> |
collectionSize(Id id,
T collection)
Register a gauge that reports the size of the
Collection . |
default <T extends Collection<?>> |
collectionSize(String name,
T collection)
Register a gauge that reports the size of the
Collection . |
default Counter |
counter(DynamicId id)
Measures the rate of some activity.
|
Counter |
counter(Id id)
Measures the rate of some activity.
|
default Counter |
counter(String name)
Measures the rate of some activity.
|
default Counter |
counter(String name,
Iterable<Tag> tags)
Measures the rate of some activity.
|
default Counter |
counter(String name,
String... tags)
Measures the rate of some activity.
|
default java.util.stream.Stream<Counter> |
counters()
Returns a stream of all registered counters.
|
default DynamicId |
createDynamicId(String name)
Creates a dynamic identifier for a meter.
|
default DynamicId |
createDynamicId(String name,
Iterable<TagFactory> tagFactories)
Creates a dynamic identifier for a meter.
|
Id |
createId(String name)
Creates an identifier for a meter.
|
Id |
createId(String name,
Iterable<Tag> tags)
Creates an identifier for a meter.
|
default Id |
createId(String name,
Map<String,String> tags)
Creates an identifier for a meter.
|
default Id |
createId(String name,
String... tags)
Creates an identifier for a meter.
|
default java.util.stream.Stream<DistributionSummary> |
distributionSummaries()
Returns a stream of all registered distribution summaries.
|
default DistributionSummary |
distributionSummary(DynamicId id)
Measures the rate and variation in amount for some activity.
|
DistributionSummary |
distributionSummary(Id id)
Measures the rate and variation in amount for some activity.
|
default DistributionSummary |
distributionSummary(String name)
Measures the sample distribution of events.
|
default DistributionSummary |
distributionSummary(String name,
Iterable<Tag> tags)
Measures the sample distribution of events.
|
default DistributionSummary |
distributionSummary(String name,
String... tags)
Measures the sample distribution of events.
|
default <T extends Number> |
gauge(Id id,
T number)
Register a gauge that reports the value of the
Number . |
default <T> T |
gauge(Id id,
T obj,
java.util.function.ToDoubleFunction<T> f)
Register a gauge that reports the value of the object after the function
f is applied. |
default <T> T |
gauge(Id id,
T obj,
ValueFunction<T> f)
Deprecated.
|
default <T extends Number> |
gauge(String name,
Iterable<Tag> tags,
T number)
Register a gauge that reports the value of the
Number . |
default <T extends Number> |
gauge(String name,
T number)
Register a gauge that reports the value of the
Number . |
default <T> T |
gauge(String name,
T obj,
java.util.function.ToDoubleFunction<T> f)
Register a gauge that reports the value of the object.
|
default <T> T |
gauge(String name,
T obj,
ValueFunction<T> f)
Deprecated.
|
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.
|
default LongTaskTimer |
longTaskTimer(Id id)
Measures the time taken for long tasks.
|
default LongTaskTimer |
longTaskTimer(String name)
Measures the time taken for long tasks.
|
default LongTaskTimer |
longTaskTimer(String name,
Iterable<Tag> tags)
Measures the time taken for long tasks.
|
default LongTaskTimer |
longTaskTimer(String name,
String... tags)
Measures the time taken for long tasks.
|
default <T extends Map<?,?>> |
mapSize(Id id,
T collection)
Register a gauge that reports the size of the
Map . |
default <T extends Map<?,?>> |
mapSize(String name,
T collection)
Register a gauge that reports the size of the
Map . |
default void |
methodValue(Id id,
Object obj,
String method)
Register a gauge that reports the return value of invoking the method on the object.
|
default void |
methodValue(String name,
Object obj,
String method)
Register a gauge that reports the return value of invoking the method on the object.
|
void |
register(Meter meter)
Add a custom meter to the registry.
|
default java.util.stream.Stream<Meter> |
stream()
Returns a stream of all registered meters.
|
default Timer |
timer(DynamicId id)
Measures the rate and time taken for short running tasks.
|
Timer |
timer(Id id)
Measures the rate and time taken for short running tasks.
|
default Timer |
timer(String name)
Measures the time taken for short tasks.
|
default Timer |
timer(String name,
Iterable<Tag> tags)
Measures the time taken for short tasks.
|
default Timer |
timer(String name,
String... tags)
Measures the time taken for short tasks.
|
default java.util.stream.Stream<Timer> |
timers()
Returns a stream of all registered timers.
|
default <T extends Registry> |
underlying(Class<T> c)
Returns the first underlying registry that is an instance of
c . |
forEach, spliterator
Clock clock()
Id createId(String name)
name
- Description of the measurement that is being collected.Id createId(String name, Iterable<Tag> tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default DynamicId createDynamicId(String name)
name
- Description of the measurement that is being collected.default DynamicId createDynamicId(String name, Iterable<TagFactory> tagFactories)
name
- Description of the measurement that is being collected.tagFactories
- Other factories that can generate other dimensions that can be used to classify the measurement.void register(Meter meter)
Counter counter(Id id)
id
- Identifier created by a call to createId(java.lang.String)
default Counter counter(DynamicId id)
id
- Identifier created by a call to createDynamicId(java.lang.String)
DistributionSummary distributionSummary(Id id)
id
- Identifier created by a call to createId(java.lang.String)
default DistributionSummary distributionSummary(DynamicId id)
id
- Identifier created by a call to createDynamicId(java.lang.String)
Timer timer(Id id)
id
- Identifier created by a call to createId(java.lang.String)
default Timer timer(DynamicId id)
id
- Identifier created by a call to createDynamicId(java.lang.String)
Meter get(Id id)
id
- Identifier for the meter.default <T extends Registry> T underlying(Class<T> c)
c
.default Id createId(String name, String... tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default Id createId(String name, Map<String,String> tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default Counter counter(String name)
name
- Description of the measurement that is being collected.default Counter counter(String name, Iterable<Tag> tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default Counter counter(String name, String... tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default DistributionSummary distributionSummary(String name)
name
- Description of the measurement that is being collected.default DistributionSummary distributionSummary(String name, Iterable<Tag> tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default DistributionSummary distributionSummary(String name, String... tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default Timer timer(String name)
name
- Description of the measurement that is being collected.default Timer timer(String name, Iterable<Tag> tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default Timer timer(String name, String... tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default LongTaskTimer longTaskTimer(Id id)
id
- Identifier for the metric being registered.default LongTaskTimer longTaskTimer(String name)
name
- Description of the measurement that is being collected.default LongTaskTimer longTaskTimer(String name, Iterable<Tag> tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default LongTaskTimer longTaskTimer(String name, String... tags)
name
- Description of the measurement that is being collected.tags
- Other dimensions that can be used to classify the measurement.default <T extends Number> T gauge(Id id, T number)
Number
. The registration
will keep a weak reference to the number so it will not prevent garbage collection.
The number implementation used should be thread safe.id
- Identifier for the metric being registered.number
- Thread-safe implementation of Number
used to access the value.default <T extends Number> T gauge(String name, T number)
Number
. See
gauge(Id, Number)
.name
- Name of the metric being registered.number
- Thread-safe implementation of Number
used to access the value.default <T extends Number> T gauge(String name, Iterable<Tag> tags, T number)
Number
. See
gauge(Id, Number)
.name
- Name of the metric being registered.tags
- Sequence of dimensions for breaking down the name.number
- Thread-safe implementation of Number
used to access the value.default <T> T gauge(Id id, T obj, java.util.function.ToDoubleFunction<T> f)
f
is applied. The registration will keep a weak reference to the number so it will
not prevent garbage collection. The number implementation used should be thread safe.id
- Identifier for the metric being registered.obj
- Object used to compute a value.f
- Function that is applied on the value for the number.default <T> T gauge(String name, T obj, java.util.function.ToDoubleFunction<T> f)
gauge(Id, Object, ToDoubleFunction)
.name
- Name of the metric being registered.obj
- Object used to compute a value.f
- Function that is applied on the value for the number.@Deprecated default <T> T gauge(Id id, T obj, ValueFunction<T> f)
gauge(Id, Object, ToDoubleFunction)
.f
is applied. The registration will keep a weak reference to the number so it will
not prevent garbage collection. The number implementation used should be thread safe.id
- Identifier for the metric being registered.obj
- Object used to compute a value.f
- Function that is applied on the value for the number.@Deprecated default <T> T gauge(String name, T obj, ValueFunction<T> f)
gauge(String, Object, ToDoubleFunction)
.gauge(Id, Object, ToDoubleFunction)
.name
- Name of the metric being registered.obj
- Object used to compute a value.f
- Function that is applied on the value for the number.default <T extends Collection<?>> T collectionSize(Id id, T collection)
Collection
. The registration
will keep a weak reference to the collection so it will not prevent garbage collection.
The collection implementation used should be thread safe. Note that calling
Collection.size()
can be expensive for some collection implementations
and should be considered before registering.id
- Identifier for the metric being registered.collection
- Thread-safe implementation of Collection
used to access the value.default <T extends Collection<?>> T collectionSize(String name, T collection)
Collection
. The registration
will keep a weak reference to the collection so it will not prevent garbage collection.
The collection implementation used should be thread safe. Note that calling
Collection.size()
can be expensive for some collection implementations
and should be considered before registering.name
- Name of the metric being registered.collection
- Thread-safe implementation of Collection
used to access the value.default <T extends Map<?,?>> T mapSize(Id id, T collection)
Map
. The registration
will keep a weak reference to the collection so it will not prevent garbage collection.
The collection implementation used should be thread safe. Note that calling
Map.size()
can be expensive for some collection implementations
and should be considered before registering.id
- Identifier for the metric being registered.collection
- Thread-safe implementation of Map
used to access the value.default <T extends Map<?,?>> T mapSize(String name, T collection)
Map
. The registration
will keep a weak reference to the collection so it will not prevent garbage collection.
The collection implementation used should be thread safe. Note that calling
Map.size()
can be expensive for some collection implementations
and should be considered before registering.name
- Name of the metric being registered.collection
- Thread-safe implementation of Map
used to access the value.default void methodValue(Id id, Object obj, String method)
id
- Identifier for the metric being registered.obj
- Object used to compute a value.method
- Name of the method to invoke on the object.default void methodValue(String name, Object obj, String method)
name
- Name of the metric being registered.obj
- Object used to compute a value.method
- Name of the method to invoke on the object.default java.util.stream.Stream<Meter> stream()
default java.util.stream.Stream<Counter> counters()
LongSummaryStatistics summary = r.counters() .filter(Functions.nameEquals("foo")) .collect(Collectors.summarizingLong(Counter::count));
default java.util.stream.Stream<DistributionSummary> distributionSummaries()
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();
default java.util.stream.Stream<Timer> timers()
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();