Package io.micrometer.common.annotation
Class AnnotationHandler<T>
java.lang.Object
io.micrometer.common.annotation.AnnotationHandler<T>
- Type Parameters:
T
- type which should be enriched withKeyValue
information
This class is able to find all methods annotated with the Micrometer annotations. All
methods mean that if you have both an interface and an implementation annotated with
Micrometer annotations then this class is capable of finding both of them and merging
into one set of information.
This information is then used to add proper key-values to objects such as span or timer from the method arguments that are annotated with a proper annotation. Code ported from Spring Cloud Sleuth.
- Since:
- 1.11.0
-
Constructor Summary
ConstructorDescriptionAnnotationHandler
(BiConsumer<KeyValue, T> keyValueConsumer, Function<Class<? extends ValueResolver>, ? extends ValueResolver> resolverProvider, Function<Class<? extends ValueExpressionResolver>, ? extends ValueExpressionResolver> expressionResolverProvider, Class<? extends Annotation> annotation, BiFunction<Annotation, Object, KeyValue> toKeyValue) Creates a new instance ofAnnotationHandler
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAnnotatedParameters
(T objectToModify, org.aspectj.lang.ProceedingJoinPoint pjp) Modifies the object withKeyValue
related information.Function
<Class<? extends ValueExpressionResolver>, ? extends ValueExpressionResolver> Function
<Class<? extends ValueResolver>, ? extends ValueResolver>
-
Constructor Details
-
AnnotationHandler
public AnnotationHandler(BiConsumer<KeyValue, T> keyValueConsumer, Function<Class<? extends ValueResolver>, ? extends ValueResolver> resolverProvider, Function<Class<? extends ValueExpressionResolver>, ? extends ValueExpressionResolver> expressionResolverProvider, Class<? extends Annotation> annotation, BiFunction<Annotation, Object, KeyValue> toKeyValue) Creates a new instance ofAnnotationHandler
.- Parameters:
keyValueConsumer
- consumer that takes aKeyValue
and mutates the<T>
typeresolverProvider
- function converting a class extending aValueResolver
to an instance of that classexpressionResolverProvider
- function converting a class extending aValueExpressionResolver
to an instance of that classannotation
- annotation containingKeyValue
related informationtoKeyValue
- function converting the annotation and the expression or annotation value to aKeyValue
-
-
Method Details
-
addAnnotatedParameters
Modifies the object withKeyValue
related information.- Parameters:
objectToModify
- object to modifypjp
- proceeding join point
-
getResolverProvider
-
getExpressionResolverProvider
public Function<Class<? extends ValueExpressionResolver>,? extends ValueExpressionResolver> getExpressionResolverProvider()
-