micrometer icon indicating copy to clipboard operation
micrometer copied to clipboard

Provide an option to supply common tags for registries.

Open lenin-jaganathan opened this issue 1 year ago • 9 comments

Please describe the feature request. This thought arrived during a discussion on https://github.com/micrometer-metrics/micrometer/issues/2818. The thought process is that MeterRegistries can take common tags static to a JVM (like app_name, host_name, region, manifest, and whatnot) and use that to append as metadata while sending metrics (if the back-end supports that) or at least use those common tags to get translated to corresponding systems tag equivalent once and use it for every publish.

Rationale

  • Some backends have provisions to add common metadata once per request, so we can avoid referencing tags/creating new ones if we have common tags.
  • Some registries convert the tags to their system equivalent thing (dimensions/labels) etc and they do it for every meter. This generates too much garbage as this is only needed to send the data for that Step. If static objects were created during the initialization, the same objects can be attached to all the metrics and we can avoid allocations.
  • Sometimes, users ended up creating multiple tag objects with the same tag key and name this extra allocation to go to Old gen, these can be completely eliminated

lenin-jaganathan avatar Apr 06 '23 12:04 lenin-jaganathan

Well, this issue is subtly different from the existing "commonTags" method which adds the commonTags to all the meters which are processed once every step interval.

lenin-jaganathan avatar Apr 07 '23 13:04 lenin-jaganathan

Why won't a MeterFilter be a good idea to add such tags?

marcingrzejszczak avatar Dec 20 '23 16:12 marcingrzejszczak

Because it is not so efficient to do it every time we interact with the meter. A 1x1 example is OpenTelemetry's Resource, where unique information can be store once and re-used multiple times.

If we try to do this in a meterfilter, every single time a meter needs to be recorded we have to run through the filter and add tags and them record the value on it.

E.g: Let's I have a service fooserv and I need this info to be added to all the meters.

If I add a meter filter, every time I want to record metric for a HTTP request, initially i would create a meter with information like path, status and etc. When I call register on the meter, the filters get executed and it tries to add a new tag service=fooserv. Since Meter.Id is immutable this creates a new object and registers it. This is the additional hop I am talking about.

Alternatively, if We can say to the registry that service=fooserv is needed on all the metric, it can add that information during export time alone to the actual protocol it talks to.

lenin-jaganathan avatar Dec 20 '23 17:12 lenin-jaganathan

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

github-actions[bot] avatar Jan 02 '24 10:01 github-actions[bot]

@marcingrzejszczak How can we prevent an auto close on this issue?

lenin-jaganathan avatar Jan 08 '24 12:01 lenin-jaganathan

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

github-actions[bot] avatar Jan 17 '24 01:01 github-actions[bot]

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open.

github-actions[bot] avatar Jan 24 '24 01:01 github-actions[bot]

This seems to have been closed unintentionally by the bot.

izeye avatar Jan 25 '24 15:01 izeye

We need to look into why the bot ignores comments, it seems it closes every issue that has the waiting for feedback label. :(

jonatan-ivanov avatar Jan 25 '24 17:01 jonatan-ivanov