Open kinddevil opened 3 years ago
When overwriting the extraTags in Aspect, the behavior is different - extraTags can be replaced in the TimedAspect but in CountedAspect as below.
extraTags
TimedAspect
CountedAspect
I have a function with extra tags like
@Timed(extraTags = {"extra", "A"}) @Counted(extraTags = {"extra", "B"}) public void recordMetrics() { ... }
When I overwrite the extra tag in TimedAspect
extra
@Bean public TimedAspect timedAspect(MeterRegistry registry) { return new TimedAspect(registry, p -> Arrays.asList(Tag.of("extra", "AA")); }
The extra changed to AA successfully. But when I use some similar code in CountedAspect it failed.
AA
@Bean public CountedAspect countedAspect(MeterRegistry registry) { return new CountedAspect(registry, p -> Arrays.asList(Tag.of("extra", "BB")); }
The value is still B.
B
It is because of the different orders when applying the ProceedingJoinPoint tags https://github.com/micrometer-metrics/micrometer/blob/939e0e4a36cc3bf05785c6436f1f7a72e710c9d9/micrometer-core/src/main/java/io/micrometer/core/aop/CountedAspect.java#L148 and https://github.com/micrometer-metrics/micrometer/blob/939e0e4a36cc3bf05785c6436f1f7a72e710c9d9/micrometer-core/src/main/java/io/micrometer/core/aop/TimedAspect.java#L192.
ProceedingJoinPoint
Can we make them in the same order?
There is a fix for the issue https://github.com/micrometer-metrics/micrometer/pull/2462, can someone take a look? Thank you!
Hi @shakuzen, do you have any suggestions for this issue?
When overwriting the
extraTags
in Aspect, the behavior is different -extraTags
can be replaced in theTimedAspect
but inCountedAspect
as below.I have a function with extra tags like
When I overwrite the
extra
tag inTimedAspect
The
extra
changed toAA
successfully. But when I use some similar code inCountedAspect
it failed.The value is still
B
.It is because of the different orders when applying the
ProceedingJoinPoint
tags https://github.com/micrometer-metrics/micrometer/blob/939e0e4a36cc3bf05785c6436f1f7a72e710c9d9/micrometer-core/src/main/java/io/micrometer/core/aop/CountedAspect.java#L148 and https://github.com/micrometer-metrics/micrometer/blob/939e0e4a36cc3bf05785c6436f1f7a72e710c9d9/micrometer-core/src/main/java/io/micrometer/core/aop/TimedAspect.java#L192.Can we make them in the same order?