Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Micrometer-bridge breaks Spring Actuator metrics #12719

Open
santerivairio opened this issue Nov 13, 2024 · 2 comments
Open

Micrometer-bridge breaks Spring Actuator metrics #12719

santerivairio opened this issue Nov 13, 2024 · 2 comments
Labels
bug Something isn't working needs triage New issue that requires triage

Comments

@santerivairio
Copy link

Describe the bug

Using javaagent and spring actuator with micrometer bridge enabled breaks sometimes the /metrics -endpoint.
In those cases it seems like the OpenTelemetryMetricsRegistry is created before PrometheusMetricsRegistry.

In those cases an error stating io.opentelemetry.javaagent.shaded.instrumentation.micrometer.v1_5.OpenTelemetryMeterRegistry - OpenTelemetry metrics bridge does not support reading measurements is shown.

But it some cases the same exact implementation works after restarting the application. In those cases the PrometheusMetricsRegistry is before the OpenTelemetry one in the registries-Set

We're using custom micrometer metrics that need to be bridged for the OpenTelemetry agent too.

Seems like the issue is that spring-actuator's metrics endpoint implementation uses the first registry that has the wanted metric in it. But because OpenTelemetryMeterRegistry is unreadable, the response is empty (no measurement value). Here's the cause of this issue.

We managed to fix this by overriding the MetricsEndpoint-implementation with a one that excludes OpenTelemetryMetricsRegistry. But in my opinion it would be nicer to have it fixed somewhere else, here perhaps?

Steps to reproduce

spring-boot-starter-actuator 3.2.5
opentelemetry-javaagent 2.9.0
micrometer bridge enabled
query metrics through actuator /actuator/metrics/<metric name>

Expected behavior

No errors, wouldn't require booting until the registries are in correct order

Actual behavior

io.opentelemetry.javaagent.shaded.instrumentation.micrometer.v1_5.OpenTelemetryMeterRegistry - OpenTelemetry metrics bridge does not support reading measurements is shown.

But it some cases the same exact implementation works after restarting the application. In those cases the PrometheusMetricsRegistry is before the OpenTelemetry one in the registries-Set

Javaagent or library instrumentation version

v2.9.0

Environment

JDK: Temurin 17.0.12
OS: eclipse-temurin:17-jre-alpine
Spring Boot 3.2.5

Additional context

No response

@santerivairio santerivairio added bug Something isn't working needs triage New issue that requires triage labels Nov 13, 2024
@trask
Copy link
Member

trask commented Nov 20, 2024

maybe we need to add PrometheusMetricsRegistry here?

// configure after the SimpleMeterRegistry has initialized; it is normally the last MeterRegistry
// implementation to be configured, as it's used as a fallback
// the OTel registry should be added in addition to that fallback and not replace it
@AutoConfigureAfter(SimpleMetricsExportAutoConfiguration.class)

also I noticed that the Spring Boot Starter uses a different @AutoConfigureAfter below, I'm not sure why it's different, maybe it's better? cc @jeanbisutti @zeitlinger

@zeitlinger
Copy link
Member

I don't know why @AutoConfigureAfter is different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

3 participants