Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optional observation tag for labels is incompatible with Prometheus registry #2752

Open
hpoettker opened this issue Feb 17, 2025 · 0 comments · May be fixed by #2757
Open

Optional observation tag for labels is incompatible with Prometheus registry #2752

hpoettker opened this issue Feb 17, 2025 · 0 comments · May be fixed by #2757
Labels
Milestone

Comments

@hpoettker
Copy link
Contributor

hpoettker commented Feb 17, 2025

Bug description

The ObservationEnvironmentRepositoryObservationConvention sets the tags for environment class, profile, application, and label on the observations only when the respective values are non-blank.

This is a problem for the Prometheus registry as Prometheus expects the same set of tags to be set with every observation.
When an observation with a different set of tags compared to previous observations is registered, the new observation will be dropped.

An example would be a client request that asks for specific label after previously only requests without a specific label have been requested.
When the Prometheus registry is used, the requests for a specific label will be dropped in this scenario.

Steps to reproduce

A full minimal complete verifiable example can be found here: https://github.com/hpoettker/config-server-reproducer

In short, a reproducing app can be created as follows:

  • create a new project with the following dependencies:
    • Spring Cloud Config Server
    • Spring Boot Starter Actuator
    • Prometheus Registry
  • add @EnableConfigServer
  • expose the actuator's Prometheus end-point in the application.yml

Then, start up the application in the profile native, and execute the following requests:

curl http://localhost:8080/application/default

followed by

curl http://localhost:8080/application/default/label

The client will receive the expected responses but the the following warning will be logged:

The meter (MeterId{name='spring.cloud.config.environment.find.active', tags=[tag(spring.cloud.config.environment.application=application),tag(spring.cloud.config.environment.class=org.springframework.cloud.config.server.environment.SearchPathCompositeEnvironmentRepository),tag(spring.cloud.config.environment.label=label),tag(spring.cloud.config.environment.profile=default)]}) 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 'spring.cloud.config.environment.find.active' containing tag keys [spring.cloud.config.environment.application, spring.cloud.config.environment.class, spring.cloud.config.environment.profile].
The meter you are attempting to register has keys [spring.cloud.config.environment.application, spring.cloud.config.environment.class, spring.cloud.config.environment.label, spring.cloud.config.environment.profile].
Note that subsequent logs will be logged at debug level.

When checking the response of the end-point for the meter spring_cloud_config_environment_find_active, the second request with the label is missing from the statistics.

ryanjbaxter added a commit to ryanjbaxter/spring-cloud-config that referenced this issue Feb 22, 2025
@ryanjbaxter ryanjbaxter linked a pull request Feb 22, 2025 that will close this issue
@ryanjbaxter ryanjbaxter linked a pull request Feb 22, 2025 that will close this issue
@ryanjbaxter ryanjbaxter added this to the 4.1.6 milestone Feb 22, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Status: No status
Status: No status
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants