Description
Currently a custom convention can be achieved only by going through the micrometer global conventions: SomeCustom implementes GlobalObservationConvention<ScheduledTaskObservationContext>
which need to be extra registered in a ObservationRegistryCustomizer bean
@Bean
public ObservationRegistryCustomizer<ObservationRegistry> observationRegistryCustomizer() {
return registry ->
registry.observationConfig()
.observationConvention(new SomeCustom());
}
This though is making it impossible to re-use the default code from the DefaultScheduledTaskObservationConvention
because the observation registry -> observationConfig -> observationConvention method is expecting a GlobalObservationConvention<?>
whereas a DefaultScheduledTaskObservationConvention
is in a slight different chain of the ObservationConvention
inheritance.
Would it be feasible/possible to let the ScheduledMethodRunnable
arrange its convention similar to the RestClientObservationConfiguration
for example, where a simple component or a bean extending the DefaultClientRequestObservationConvention
is enough to be used as a custom convention for the http.client.requests
metrics.
Not sure what is the reason, but these customizations of conventions seem to not follow a consistent approach in general, see the recently fixed situation for the DefaultMongoHandlerObservationConvention, also in general:
- extending
DefaultServerRequestObservationConvention
// works like a charm for the http.server.requests metrics - extending
DefaultClientRequestObservationConvention
// works like a charm for the http.client.requests metrics - extending
DefaultRepositoryTagsProvider
// works like a charm for the spring.data.repository.invocations metrics though differs from first two ones - extending
DefaultMongoCommandTagsProvider
// works like a charm for the mongodb.driver.commands metrics though differs from first two ones - implementing
GlobalObservationConvention<ScheduledTaskObservationContext>
// works for the tasks.scheduled.execution metrics, but as described above - only after manually adding it as part of a custom bean configuration of theObservationRegistryCustomizer<ObservationRegistry>
...observationRegistry.observationConfig().observationConvention(...)