Skip to content

Support common-tags alias for Micrometer common tags#1155

Open
n0tl3ss wants to merge 4 commits into
6.0.xfrom
nmikic/prometheus-common-tags-regression
Open

Support common-tags alias for Micrometer common tags#1155
n0tl3ss wants to merge 4 commits into
6.0.xfrom
nmikic/prometheus-common-tags-regression

Conversation

@n0tl3ss

@n0tl3ss n0tl3ss commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

  • add regression coverage for Prometheus common tags applied before meters are registered
  • support both micronaut.metrics.tags.* and micronaut.metrics.common-tags.* when building common tags
  • document micronaut.metrics.common-tags.* as the clearer alias while keeping the legacy prefix working

Verification

  • ./gradlew :micronaut-micrometer-core:test --rerun-tasks --tests 'io.micronaut.configuration.metrics.management.endpoint.MetricsEndpointSpec' --tests 'io.micronaut.configuration.metrics.micrometer.MeterRegistryConfigurerOrderSpec'
  • ./gradlew :micronaut-micrometer-registry-prometheus:test --tests 'io.micronaut.configuration.metrics.micrometer.prometheus.PrometheusMeterRegistryFactorySpec'

Resolves #114

Co-Authored-By: Codex with GPT-5 <codex@openai.com>
@n0tl3ss n0tl3ss self-assigned this Apr 24, 2026
@n0tl3ss n0tl3ss added the type: bug Something isn't working label Apr 24, 2026
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
@n0tl3ss n0tl3ss changed the title Add Prometheus common tags regression coverage Support common-tags alias for Micrometer common tags Apr 24, 2026
@n0tl3ss
n0tl3ss requested review from alvarosanchez, Copilot and sdelamo and removed request for Copilot April 27, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds support for the micronaut.metrics.common-tags.* alias (while keeping the legacy micronaut.metrics.tags.* working) and adds regression coverage to ensure common tags are applied before meters are registered.

Changes:

  • Added documentation describing micronaut.metrics.common-tags.* as the preferred alias while supporting the legacy prefix.
  • Updated common-tag resolution logic to merge tags from both prefixes.
  • Added/updated Spock specs to cover both prefixes and a Prometheus-specific ordering regression.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/docs/guide/metricsConcepts.adoc Documents the new common-tags alias and provides configuration example.
micrometer-registry-prometheus/src/test/groovy/io/micronaut/configuration/metrics/micrometer/prometheus/PrometheusMeterRegistryFactorySpec.groovy Adds regression test ensuring common tags are applied before meter registration.
micrometer-core/src/test/groovy/io/micronaut/configuration/metrics/micrometer/MeterRegistryConfigurerOrderSpec.groovy Updates expected configurer count/order now that common tags are conditional.
micrometer-core/src/test/groovy/io/micronaut/configuration/metrics/management/endpoint/MetricsEndpointSpec.groovy Parameterizes common-tags test to validate both property prefixes.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/micrometer/MeterRegistryFactory.java Introduces distinct constants for legacy tags vs alias common-tags.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/common/tags/CommonTagsConfigurer.java Reads tags from both prefixes via Environment and applies them as common tags.
micrometer-core/src/main/java/io/micronaut/configuration/metrics/common/tags/CommonTagsCondition.java Activates common-tags configurer when either prefix is configured.

n0tl3ss and others added 2 commits April 27, 2026 17:14
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Random "There is already an existing meter named" exception after adding "meterRegistry.config().commonTags"

3 participants