Skip to content

Commit 7b27b7f

Browse files
committed
Add support for OTEL_EXPORTER_OTLP_COMPRESSION environment variable
Add fallback to the generic OTEL_EXPORTER_OTLP_COMPRESSION environment variable when the metrics-specific variable is not set. Signed-off-by: Tigran Kavanosyan <allnightlong@allnightlong.ru>
1 parent fcd615d commit 7b27b7f

File tree

1 file changed

+9
-3
lines changed
  • implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp

1 file changed

+9
-3
lines changed

implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpConfig.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,21 @@ default AggregationTemporality aggregationTemporality() {
159159
/**
160160
* {@link CompressionMode} of the OtlpMeterRegistry. This determines whether the
161161
* metrics data should be compressed before being sent to the OTLP endpoint. Default
162-
* implementation supports the environment variable
162+
* implementation supports the environment variables
163+
* {@code OTEL_EXPORTER_OTLP_COMPRESSION} and
163164
* {@code OTEL_EXPORTER_OTLP_METRICS_COMPRESSION} when a value is not provided by
164-
* {@link #get(String)}.
165+
* {@link #get(String)}. If both are set, {@code OTEL_EXPORTER_OTLP_METRICS_COMPRESSION}
166+
* takes precedence.
165167
* @return the compressionMode; default is OFF
166168
* @since 1.17.0
167169
*/
168170
default CompressionMode compressionMode() {
169171
return getEnum(this, CompressionMode.class, "compressionMode").orElseGet(() -> {
170-
String compression = System.getenv().get("OTEL_EXPORTER_OTLP_METRICS_COMPRESSION");
172+
Map<String, String> env = System.getenv();
173+
String compression = env.get("OTEL_EXPORTER_OTLP_METRICS_COMPRESSION");
174+
if (compression == null) {
175+
compression = env.get("OTEL_EXPORTER_OTLP_COMPRESSION");
176+
}
171177
if (compression != null) {
172178
return CompressionMode.valueOf(compression.toUpperCase(Locale.ROOT));
173179
}

0 commit comments

Comments
 (0)