Skip to content

PrometheusNamingConvention duplicates "_seconds" suffix with default configuration for Timer metrics #2320

Closed

Description

@Fetsivalen

Version: Latest

By default in PrometheusMeterRegistry configured PrometheusNamingConvention with default constructor which configures "" value in timerSuffix.

And when the method name called for the Timer metric, it will append the _seconds suffix even when it is already present.
see: this switch case

At the same time, that implementation won't add _total suffix for counter metrics.
see: this switch case.

Am I missing some intentional reason why it is happening in this way or it is a bug?

Activity

  1. added
    registry: prometheus
    on Oct 29, 2020
  2. shakuzen commented on Oct 29, 2020

    @shakuzen
    Member

    That code has not changed since 1.0, but it does look potentially off. The intention was to support an alternate naming convention for timers that used an additional suffix before _seconds (see PrometheusDurationNamingConvention). It doesn't look like we consider the case for the default of a blank "" suffix and a meter name that already ends in seconds, which I believe is what this issue is reporting. I would say it is also best practice to not name Timers ending in seconds generally, anyways, though. We could still probably improve the logic and unit tests here.
    /cc @checketts who added the PrometheusDurationNamingConvention.

  3. Fetsivalen commented on Oct 29, 2020

    @Fetsivalen
    ContributorAuthor

    Hi @shakuzen
    First of all thanks for the fast response.

    Actually, my issue is not about the naming of the metrics itself.

    I used PrometheusNamingConvention to generate dashboards from the source code and different users are able to provide metric names either from Prometheus endpoint, or the ones they pass to the meter registry.

    Of course, I can resolve it inside my own code, but it seems to me that behavior in PrometheusNamingConvention is not consistent for the Timers and Counters.

    I'd be happy to contribute this feature but the change seems like breaking change to me, and I wonder whether it will be welcomed, and what is the process of such changes.

  4. checketts commented on Oct 29, 2020

    @checketts
    Contributor

    I can't recall why it was implemented as is. The blame looks like I just reformatted the code. So that isn't very helpful.

    It appears the current logic is intended to make the suffix _duration_seconds or just _seconds, feel free to add the missing case @shakuzen mentioned.

  5. Fetsivalen commented on Apr 2, 2021

    @Fetsivalen
    ContributorAuthor

    Hi @shakuzen
    are you going to merge this PR, or it isn't smth you'd like to have in micrometer and I should close this ticket?

  6. added
    bug
    on Oct 14, 2021
  7. added this to the 1.8.0-RC1 milestone on Oct 14, 2021
  8. added a commit that references this issue on Oct 14, 2021
    75cd4b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugregistry: prometheus

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions