Skip to content

Add auto-configuration for OpenTelemetry SdkMeterProvider #46640

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThomasVitale
Copy link

@ThomasVitale ThomasVitale commented Jul 31, 2025

  • Introduced metrics sub-package in the spring-boot-opentelemetry module.
  • Provided auto-configuration for SdkMeterProvider with customisation options via configuration properties and customizer bean.
  • Defined missing OpenTelemetry Clock bean used to initialise observability signals providers.
  • Added automated tests for the newly added auto-configuration.

Fixes gh-36546

ObjectProvider<SdkMeterProviderBuilderCustomizer> customizers) {
SdkMeterProviderBuilder builder = SdkMeterProvider.builder().setClock(clock).setResource(resource);
if (properties.getExemplars().isEnabled()) {
SdkMeterProviderUtil.setExemplarFilter(builder, exemplarFilter);
Copy link
Author

Choose a reason for hiding this comment

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

Exemplars are disabled by default because even though the Spec/API is GA, the method in the Java SDK to configure them is not exposed publicly, but through this util. Is that acceptable for Spring Boot?

The API (mapped closely by the configuration properties) won't change as it's stable. So, any change to the SDK internals will not require any code/configuration change from Spring Boot users (a.k.a. stable feature). See: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#exemplar (stable API). More context: open-telemetry/opentelemetry-java#7503.

My recommendation would be to keep this functionality, but disabled by default. Considering that the OTLP Meter Registry doesn't support exemplars yet, this would be the only way in Spring Boot to support exemplars in OpenTelemetry.

@ThomasVitale ThomasVitale marked this pull request as ready for review August 1, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide auto-configuration for OpenTelemetry metrics
2 participants