diff --git a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/mpmetrics/AnnotationHandler.java b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/mpmetrics/AnnotationHandler.java index 1645ffbe59ef5..46ff12cef8293 100644 --- a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/mpmetrics/AnnotationHandler.java +++ b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/mpmetrics/AnnotationHandler.java @@ -71,10 +71,14 @@ public void transform(TransformationContext ctx) { MetricAnnotationInfo annotationInfo = new MetricAnnotationInfo(annotation, index, classInfo, methodInfo, fieldInfo); + // preserve the original annotation target, `ctx.getTarget()` is different in case of method parameters + AnnotationInstance newAnnotation = AnnotationInstance.create(targetAnnotation, annotation.target(), + annotationInfo.getAnnotationValues()); + // Remove the existing annotation, and add a new one with all the fields ctx.transform() .remove(x -> x == annotation) - .add(targetAnnotation, annotationInfo.getAnnotationValues()) + .add(newAnnotation) .done(); } });