Reputation: 21519
I am using Spring Boot 2 + Graphite reporting and have some metrics that are receiving common tags, and some that are not.
I have two beans that are identical except for the name, both creating a timer with the same code. One of them is created first and does not have commonTags applied, the other does. e.g.,
@Autowired
MeterRegistry meterRegistry
@Bean Foo doesNotGetCommonTags() {
meterRegistry.timer(...);
...
}
@Bean MeterRegistryCustomizer<GraphiteMeterRegistry> graphiteCustomizer() {
return r -> r.config().commonTags(...);
}
@Bean Foo getsCommonTags() {
meterRegistry.timer(...);
...
}
It seems to have to do with bean creation order, but I cannot figure out how to ensure my registry is fully customised before creating meters. I’m using the common tags as a prefix, so this results in some metrics being send to Graphite unprefixed, while others are.
I don’t understand what could cause this. My graphiteCustomizer should be applied before the metrics registry is injected, right?
Upvotes: 2
Views: 724
Reputation: 21519
My workaround (which I don’t consider a full solution) was to not use MeterRegsitryCustomizer
and instead create the Graphite registry myself with my desired customisations.
Upvotes: 1