Skip to content

Optional Micrometer Tags are causing prometheus metric warnings on registration #1037

@JacobF7

Description

@JacobF7

Expected Behavior

From Micrometer's Prometheus documentation, the same metric name cannot be registered with different tags. It seems like with the latest Micronaut Parent (4.9.3) with the Micronaut Micrometer version 5.12.0, there are places where certain tags are not being added:

WebMetricsHelper

private static @Nullable Tag serviceId(@Nullable String serviceId) {
     return serviceId == null ? null : Tag.of("serviceId", serviceId);
}

I am assuming that a default value should be provided for this tag.

Actual Behaviour

The above issue is causing the following warning:

This causes the following warning

The meter (MeterId{name='http.client.requests', tags=[tag(exception=none),tag(method=GET),tag(status=200),tag(uri=UNKNOWN)]}) registration has failed: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'http_client_requests_seconds' containing tag keys [exception, method, serviceId, status, uri]. The meter you are attempting to register has keys [exception, method, status, uri]. Note that subsequent logs will be logged at debug level.

Steps To Reproduce

  1. Depend on Micronaut Micrometer 5.12.0 and Micronaut Prometheus Registry
  2. Perform request without Service Id present
  3. Should log the warning

Environment Information

  • Java 21
  • Micronaut 4.9.3

Example Application

No response

Version

4.9.3, Micrometer Version 5.12.0

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