public final class MicrometerUtil extends Object
MeterIdPrefix. This can be
useful when you need to make sure you do not register the same Meter more than once.RequestMetricSupport,
CaffeineMetricSupport| Modifier and Type | Method and Description |
|---|---|
static <T> T |
register(MeterRegistry registry,
MeterIdPrefix idPrefix,
Class<T> type,
BiFunction<MeterRegistry,MeterIdPrefix,T> factory)
Associates a newly-created object with the specified
MeterIdPrefix or returns an existing one if
exists already. |
static <T> void |
registerLater(MeterRegistry registry,
MeterIdPrefix idPrefix,
Class<T> type,
BiFunction<MeterRegistry,MeterIdPrefix,T> factory)
Similar to
register(MeterRegistry, MeterIdPrefix, Class, BiFunction), but used when
a registration has to be nested, because otherwise the registration may enter an infinite loop,
as described here. |
public static <T> T register(MeterRegistry registry, MeterIdPrefix idPrefix, Class<T> type, BiFunction<MeterRegistry,MeterIdPrefix,T> factory)
MeterIdPrefix or returns an existing one if
exists already.idPrefix - the MeterIdPrefix of the objecttype - the type of the object created by factoryfactory - a factory that creates an object of type, to be associated with idPrefixtype, which may or may not be created by factoryIllegalStateException - if there is already an object of different class associated
for the same MeterIdPrefixpublic static <T> void registerLater(MeterRegistry registry, MeterIdPrefix idPrefix, Class<T> type, BiFunction<MeterRegistry,MeterIdPrefix,T> factory)
register(MeterRegistry, MeterIdPrefix, Class, BiFunction), but used when
a registration has to be nested, because otherwise the registration may enter an infinite loop,
as described here. For example:
// OK
register(registry, idPrefix, type, (r, i) -> {
registerLater(registry, anotherIdPrefix, anotherType, ...);
return ...;
});
// Not OK
register(registry, idPrefix, type, (r, i) -> {
register(registry, anotherIdPrefix, anotherType, ...);
return ...;
});
Copyright © 2020 LeanCloud. All rights reserved.