New approach to naming conventions by marcingrzejszczak · Pull Request #3255 · micrometer-metrics/micrometer (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I thought that the user might locally override the default behaviour by providing their own ObservationConvention. So IMO the flow could look like this (taken from OkHttpDocumentedObservation)

// If the user has explicitly provided a custom convention in the current instrumentation (e.g. OkHttpBuilder) then it will be picked if (customConvention != null) { convention = customConvention; } else { // If there's nothing custom that has been locally picked, find a matching convention // if there's no such matching convention pick the default one convention = registry.observationConfig().getObservationConvention(okHttpContext, new DefaultOkHttpObservationConvention(requestsMetricName)); }

In this case, ALL matching conventions are applied, but only the KeyValues and the first name.

Yeah I had some ideas that you could create hierarchies of conventions but maybe let's start with simple solutions first. I will change this to pick the first matching one instead of picking all.

Also, when you explicitly provide a convention to create an observation then there's no point in searching for a matching one. When you don't provide a convention but you provide a default name then we will search for a matching convention. Does it make sense?