-
Notifications
You must be signed in to change notification settings - Fork 41.7k
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