Skip to content

Counter metric name "whatever_created_total" is not allowed #1361

@sandrinr

Description

@sandrinr

Consider this metric registration:

Counter.builder().name("whatever_created_total").register();

It will end up with the exception:

java.lang.IllegalArgumentException: 'whatever_created': Illegal metric name: The metric name must not include the '_created' suffix.
	at io.prometheus.metrics.core.metrics.MetricWithFixedMetadata$Builder.name(MetricWithFixedMetadata.java:62)
	at io.prometheus.metrics.core.metrics.Counter$Builder.name(Counter.java:240)

This happens because the Counter strips the _total suffix before, sending it to the validation logic. The validation has a suffix list which is denying _created, even though in the example case _created is not the suffix of the metric.

Looking at the code, I think it is too naive to have one general static metrics validation logic for all metric types. For example, Counter should have validation logic, which allows _total suffixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions