Skip to content

Commit 78a14ba

Browse files
authored
Change default metric temporality to delta (#583)
1 parent b80fffa commit 78a14ba

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

CHANGELOG.next-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1+
* Switched the default of `otel.exporter.otlp.metrics.temporality.preference` from `CUMULATIVE` to `DELTA` to improve dashboarding experience with Kibana. If you want to restore the previous behaviour, you can manually override `otel.exporter.otlp.metrics.temporality.preference` to `CUMULATIVE` via JVM-properties or environment variables. - #583

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ in the [`span-stacktrace`](https://github.com/open-telemetry/opentelemetry-java-
7979
Experimental runtime metrics are enabled by default.
8080
Set `otel.instrumentation.runtime-telemetry.emit-experimental-telemetry` to `false` to disable them.
8181

82+
83+
### Metric Temporality
84+
85+
Elasticsearch and Kibana work best with metrics provided in delta-temporality.
86+
Therefore, the EDOT Java changes the default value of `otel.exporter.otlp.metrics.temporality.preference` to `DELTA`.
87+
You can override this default if needed, note though that some provided Kibana dashboards will not work correctly in this case.
88+
8289
# License
8390

8491
The Elastic Distribution of OpenTelemetry Java is licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html).

custom/src/main/java/co/elastic/otel/ElasticAutoConfigurationCustomizerProvider.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class ElasticAutoConfigurationCustomizerProvider
3939
private static final String DISABLED_RESOURCE_PROVIDERS = "otel.java.disabled.resource.providers";
4040
private static final String RUNTIME_EXPERIMENTAL_TELEMETRY =
4141
"otel.instrumentation.runtime-telemetry.emit-experimental-telemetry";
42+
private static final String METRIC_TEMPORALITY_PREFERENCE =
43+
"otel.exporter.otlp.metrics.temporality.preference";
4244

4345
// must match value in io.opentelemetry.contrib.stacktrace.StackTraceAutoConfig
4446
private static final String STACKTRACE_OTEL_FILTER =
@@ -76,6 +78,7 @@ static Map<String, String> propertiesCustomizer(ConfigProperties configPropertie
7678
Map<String, String> config = new HashMap<>();
7779

7880
experimentalTelemetry(config, configProperties);
81+
deltaMetricsTemporality(config, configProperties);
7982
resourceProviders(config, configProperties);
8083
spanStackTrace(config, configProperties);
8184

@@ -90,6 +93,14 @@ private static void experimentalTelemetry(
9093
config.put(RUNTIME_EXPERIMENTAL_TELEMETRY, Boolean.toString(experimentalTelemetry));
9194
}
9295

96+
private static void deltaMetricsTemporality(
97+
Map<String, String> config, ConfigProperties configProperties) {
98+
// enable experimental telemetry metrics by default if not explicitly disabled
99+
String temporalityPreference =
100+
configProperties.getString(METRIC_TEMPORALITY_PREFERENCE, "DELTA");
101+
config.put(METRIC_TEMPORALITY_PREFERENCE, temporalityPreference);
102+
}
103+
93104
private static void resourceProviders(
94105
Map<String, String> config, ConfigProperties configProperties) {
95106
Set<String> disabledResourceProviders =

custom/src/test/java/co/elastic/otel/ElasticAutoConfigurationCustomizerProviderTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,21 @@ void disableExperimentalRuntimeMetrics() {
6767
String value = config.get("otel.instrumentation.runtime-telemetry.emit-experimental-telemetry");
6868
assertThat(value).isEqualTo("false");
6969
}
70+
71+
@Test
72+
void ensureDefaultMetricTemporalityIsDelta() {
73+
Map<String, String> config =
74+
propertiesCustomizer(DefaultConfigProperties.create(new HashMap<>()));
75+
String value = config.get("otel.exporter.otlp.metrics.temporality.preference");
76+
assertThat(value).isEqualTo("DELTA");
77+
}
78+
79+
@Test
80+
void customizeMetricTemporalityPreference() {
81+
Map<String, String> userConfig = new HashMap<>();
82+
userConfig.put("otel.exporter.otlp.metrics.temporality.preference", "LOWMEMORY");
83+
Map<String, String> config = propertiesCustomizer(DefaultConfigProperties.create(userConfig));
84+
String value = config.get("otel.exporter.otlp.metrics.temporality.preference");
85+
assertThat(value).isEqualTo("LOWMEMORY");
86+
}
7087
}

0 commit comments

Comments
 (0)