spring-projects / spring-projects/spring-boot
Support OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION, and OTEL_METRIC_EXPORT_INTERVAL environment variables
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Description
Description
When using the Micrometer OTLP exporter in a Spring Boot application, the OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable is ignored. This works as expected when running Micrometer standalone, but not when running via Spring Boot. Other environment variables, like OTEL_EXPORTER_OTLP_METRICS_ENDPOINT work fine.
Steps to Reproduce
Set the OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable (e.g., to DELTA).
Start a Spring Boot application with Micrometer OTLP metrics export enabled.
Observe that the temporality preference is not picked up from the environment variable.
Expected Behavior
The exporter should respect the OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable when not explicitly set in properties.
Actual Behavior
The environment variable is ignored, and the default value (CUMULATIVE) is always used.
Root Cause (Analysis)
The OtlpMetricsProperties#getAggregationTemporality() method returns a default value even when not set by the user, and never returns null. This prevents the fallback logic in OtlpMetricsPropertiesConfigAdapter from calling OtlpConfig.super::aggregationTemporality, which is where Micrometer reads the environment variable.
The problem also exists for OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION, probably due to the default value set in OtlpMetricsPropertiesConfigAdapter. Setting the environment variable OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=base2_exponential_bucket_histogram seems to get ignored.
OTEL_METRIC_EXPORT_INTERVAL seems to have the same problem, but I don't know if it's due to the same reason.
Environment:
Spring Boot version: 3.5.6
Micrometer version: 1.15.4
Java version: 17
OS: macOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read OtlpMetricsProperties.java and OtlpMetricsPropertiesConfigAdapter.java, then compare their defaults with Micrometer's OtlpConfig.java fallback methods. Verify that the three environment variables are honored when corresponding properties are unset, while explicit properties continue to take precedence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100