Class MicrometerUtils
java.lang.Object
de.oktoflow.platform.support.metrics.micrometer.MicrometerUtils
Translation utilities, intentionally public.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAbstract meter creator to translate among implementation and abstraction. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.micrometer.core.instrument.config.MeterFilter[]append(io.micrometer.core.instrument.config.MeterFilter[] base, io.micrometer.core.instrument.config.MeterFilter... addition) Appendsadditiontobase.static voidapply(io.micrometer.core.instrument.MeterRegistry registry, io.micrometer.core.instrument.config.MeterFilter... filters) Applies the given list of meter filters.static de.iip_ecosphere.platform.support.metrics.MetercreateMeter(de.iip_ecosphere.platform.support.metrics.Meter meter, MicrometerUtils.MeterCreator creator) Creates a meter via an unknown implementation function.static io.micrometer.core.instrument.config.MeterFilterfilterValue(de.iip_ecosphere.platform.support.metrics.MeterFilter filter) Translates an abstracted filter into a micrometer filter.static io.micrometer.core.instrument.config.MeterFilter[]filterValue(de.iip_ecosphere.platform.support.metrics.MeterFilter... filter) Translates abstracted filters into micrometer filters.static io.micrometer.core.instrument.Meter.IdidValue(de.iip_ecosphere.platform.support.metrics.Meter.Id id) Translates an abstracted id into a micrometer id.static booleaninclude(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.config.MeterFilter... filters) Returns whether a meter id shall be included into a result set.static booleanReturns whether a meter id shall be included into a result set.static de.iip_ecosphere.platform.support.metrics.MeterFiltermmFilterValue(io.micrometer.core.instrument.config.MeterFilter filter) Translates an abstracted filter into a micrometer filter.static de.iip_ecosphere.platform.support.metrics.MeterFilter[]mmFilterValue(io.micrometer.core.instrument.config.MeterFilter... filter) Translates micrometer filters into abstracted filters.static de.iip_ecosphere.platform.support.metrics.StatisticmmStatisticValue(io.micrometer.core.instrument.Statistic value) Turns a String into aMeter.TypeusingStatistic.UNKNOWNas default.static io.micrometer.core.instrument.Meter.TypemmTypeValue(de.iip_ecosphere.platform.support.metrics.Meter.Type value) Turns a String into aMeter.TypeusingMeter.Type.OTHERas default.static Iterable<de.iip_ecosphere.platform.support.metrics.Measurement> mmWrapMeasurementIterable(Iterable<io.micrometer.core.instrument.Measurement> iter) Maps an abstracted iterable of measurements to a micrometer iterable of measurements.static Iterable<de.iip_ecosphere.platform.support.metrics.Tag> mmWrapTagIterable(Iterable<io.micrometer.core.instrument.Tag> iter) Maps an abstracted iterable of tags to a micrometer iterable of tags.static io.micrometer.core.instrument.StatisticstatisticValue(de.iip_ecosphere.platform.support.metrics.Statistic statistic) Turns a String into aMeter.TypeusingStatistic.UNKNOWNas default.static io.micrometer.core.instrument.TagtagValue(de.iip_ecosphere.platform.support.metrics.Tag tag) Translates an abstracted id into a micrometer tag.static de.iip_ecosphere.platform.support.metrics.Meter.TypetypeValue(io.micrometer.core.instrument.Meter.Type value) Turns a String into aMeter.TypeusingMeter.Type.OTHERas default.static <T extends Enum<T>>
TTurns an emum value into an enum value consideringdflt.static <T extends Enum<T>>
TTurns a string into an enum value consideringdflt.static <TS,TT> Iterable <TT> wrapIterable(Iterable<TS> iter, Function<TS, TT> func) Wraps an iterable.static <TS,TT> Iterator <TT> wrapIterator(Iterator<TS> iter, Function<TS, TT> func) Wraps an iterator.static Iterable<io.micrometer.core.instrument.Measurement> wrapMeasurementIterable(Iterable<de.iip_ecosphere.platform.support.metrics.Measurement> iter) Maps an micrometer iterable of measurements to an abstracted iterable of measurements.static Iterable<io.micrometer.core.instrument.Tag> wrapTagIterable(Iterable<de.iip_ecosphere.platform.support.metrics.Tag> iter) Maps an abstracted iterable of tags to a micrometer iterable of tags.
-
Constructor Details
-
MicrometerUtils
public MicrometerUtils()
-
-
Method Details
-
value
Turns an emum value into an enum value consideringdflt.- Type Parameters:
T- the enum type- Parameters:
cls- the enum classvalue- the value (may be null)dflt- the default value ifvaluecannot be converted/found- Returns:
- the value
-
value
Turns a string into an enum value consideringdflt.- Type Parameters:
T- the enum type- Parameters:
cls- the enum classvalue- the value as string (may be null)dflt- the default value ifvaluecannot be converted/found- Returns:
- the value
-
idValue
public static io.micrometer.core.instrument.Meter.Id idValue(de.iip_ecosphere.platform.support.metrics.Meter.Id id) Translates an abstracted id into a micrometer id.- Parameters:
id- the abstracted id- Returns:
- the micrometer id, null of not translatable
-
tagValue
public static io.micrometer.core.instrument.Tag tagValue(de.iip_ecosphere.platform.support.metrics.Tag tag) Translates an abstracted id into a micrometer tag.- Parameters:
tag- the abstracted tag- Returns:
- the micrometer tag, null of not translatable
-
filterValue
public static io.micrometer.core.instrument.config.MeterFilter filterValue(de.iip_ecosphere.platform.support.metrics.MeterFilter filter) Translates an abstracted filter into a micrometer filter.- Parameters:
filter- the abstracted filter- Returns:
- the micrometer filter, null of not translatable
-
mmFilterValue
public static de.iip_ecosphere.platform.support.metrics.MeterFilter mmFilterValue(io.micrometer.core.instrument.config.MeterFilter filter) Translates an abstracted filter into a micrometer filter.- Parameters:
filter- the abstracted filter- Returns:
- the micrometer filter, null of not translatable
-
filterValue
public static io.micrometer.core.instrument.config.MeterFilter[] filterValue(de.iip_ecosphere.platform.support.metrics.MeterFilter... filter) Translates abstracted filters into micrometer filters.- Parameters:
filter- the abstracted filters- Returns:
- the micrometer filters, null of not translatable
-
mmFilterValue
public static de.iip_ecosphere.platform.support.metrics.MeterFilter[] mmFilterValue(io.micrometer.core.instrument.config.MeterFilter... filter) Translates micrometer filters into abstracted filters.- Parameters:
filter- the micrometer filters- Returns:
- the abstracted filters, null of not translatable
-
typeValue
public static de.iip_ecosphere.platform.support.metrics.Meter.Type typeValue(io.micrometer.core.instrument.Meter.Type value) Turns a String into aMeter.TypeusingMeter.Type.OTHERas default.- Parameters:
value- the value- Returns:
- the corresponding type or
Meter.Type.OTHER
-
mmTypeValue
public static io.micrometer.core.instrument.Meter.Type mmTypeValue(de.iip_ecosphere.platform.support.metrics.Meter.Type value) Turns a String into aMeter.TypeusingMeter.Type.OTHERas default.- Parameters:
value- the value- Returns:
- the corresponding type or
Meter.Type.OTHER
-
mmStatisticValue
public static de.iip_ecosphere.platform.support.metrics.Statistic mmStatisticValue(io.micrometer.core.instrument.Statistic value) Turns a String into aMeter.TypeusingStatistic.UNKNOWNas default.- Parameters:
value- the value- Returns:
- the corresponding type or
Statistic.UNKNOWN
-
statisticValue
public static io.micrometer.core.instrument.Statistic statisticValue(de.iip_ecosphere.platform.support.metrics.Statistic statistic) Turns a String into aMeter.TypeusingStatistic.UNKNOWNas default.- Parameters:
statistic- the value- Returns:
- the corresponding type or
Statistic.UNKNOWN
-
wrapIterable
Wraps an iterable.- Type Parameters:
TS- the source typeTT- the target type- Parameters:
iter- the source iterablefunc- the translation function- Returns:
- the target iterable
-
wrapIterator
Wraps an iterator.- Type Parameters:
TS- the source typeTT- the target type- Parameters:
iter- the source iteratorfunc- the translation function- Returns:
- the target iterator
-
mmWrapMeasurementIterable
public static Iterable<de.iip_ecosphere.platform.support.metrics.Measurement> mmWrapMeasurementIterable(Iterable<io.micrometer.core.instrument.Measurement> iter) Maps an abstracted iterable of measurements to a micrometer iterable of measurements.- Parameters:
iter- the abstracted iterable- Returns:
- the micrometer iterable
-
wrapTagIterable
public static Iterable<io.micrometer.core.instrument.Tag> wrapTagIterable(Iterable<de.iip_ecosphere.platform.support.metrics.Tag> iter) Maps an abstracted iterable of tags to a micrometer iterable of tags.- Parameters:
iter- the abstracted iterable- Returns:
- the micrometer iterable
-
mmWrapTagIterable
public static Iterable<de.iip_ecosphere.platform.support.metrics.Tag> mmWrapTagIterable(Iterable<io.micrometer.core.instrument.Tag> iter) Maps an abstracted iterable of tags to a micrometer iterable of tags.- Parameters:
iter- the abstracted iterable- Returns:
- the micrometer iterable
-
wrapMeasurementIterable
public static Iterable<io.micrometer.core.instrument.Measurement> wrapMeasurementIterable(Iterable<de.iip_ecosphere.platform.support.metrics.Measurement> iter) Maps an micrometer iterable of measurements to an abstracted iterable of measurements.- Parameters:
iter- the micrometer iterable- Returns:
- the abstracted iterable
-
createMeter
public static de.iip_ecosphere.platform.support.metrics.Meter createMeter(de.iip_ecosphere.platform.support.metrics.Meter meter, MicrometerUtils.MeterCreator creator) Creates a meter via an unknown implementation function.- Parameters:
meter- the metercreator- the creator function- Returns:
- the created wrapped meter
-
append
public static io.micrometer.core.instrument.config.MeterFilter[] append(io.micrometer.core.instrument.config.MeterFilter[] base, io.micrometer.core.instrument.config.MeterFilter... addition) Appendsadditiontobase.- Parameters:
base- the base filtersaddition- the addition filters- Returns:
- the combined filter array
-
apply
public static void apply(io.micrometer.core.instrument.MeterRegistry registry, io.micrometer.core.instrument.config.MeterFilter... filters) Applies the given list of meter filters.- Parameters:
registry- the registry to apply the filters tofilters- the filters to apply
-
include
public static boolean include(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.config.MeterFilter... filters) Returns whether a meter id shall be included into a result set.- Parameters:
id- the meter idfilters- the filters to be applied. The first matching filter returningMeterFilter.MeterFilterReply.DENYwill remove a metric from the result list, anMeterFilter.MeterFilterReply.NEUTRALwill keep it as long as there is noMeterFilter.MeterFilterReply.DENYfilter until the end of the filter list andMeterFilter.MeterFilterReply.ACCEPTwill immediately accept the actual meter.- Returns:
truefor apply,falseelse
-
include
public static boolean include(String id, io.micrometer.core.instrument.config.MeterFilter... filters) Returns whether a meter id shall be included into a result set.- Parameters:
id- the meter idfilters- the filters to be applied. The first matching filter returningMeterFilter.MeterFilterReply.DENYwill remove a metric from the result list, anMeterFilter.MeterFilterReply.NEUTRALwill keep it as long as there is noMeterFilter.MeterFilterReply.DENYfilter until the end of the filter list andMeterFilter.MeterFilterReply.ACCEPTwill immediately accept the actual meter.- Returns:
truefor apply,falseelse
-