Skip to content

Commit

Permalink
Configure periodic metric reader interval with otel.metric.export.int…
Browse files Browse the repository at this point in the history
…erval (#3840)
  • Loading branch information
jack-berg committed Nov 9, 2021
1 parent cb0e02c commit 4b7e509
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions sdk-extensions/autoconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,18 @@ These properties can be used to control the maximum size of recordings per span.
|--------------------------|--------------------------|-----------------------------------------------------------------------------------|
| otel.metrics.exemplar.filter | OTEL_METRICS_EXEMPLAR_FILTER | The filter for exemplar sampling. Can be `NONE`, `ALL` or `WITH_SAMPLED_TRACE`. Default is `WITH_SAMPLED_TRACE`.|

## Interval metric reader
## Periodic Metric Reader

| System property | Environment variable | Description |
|--------------------------|--------------------------|-----------------------------------------------------------------------------------|
| otel.imr.export.interval | OTEL_IMR_EXPORT_INTERVAL | The interval, in milliseconds, between pushes to the exporter. Default is `60000`.|
| otel.metric.export.interval | OTEL_METRIC_EXPORT_INTERVAL | The interval, in milliseconds, between the start of two export attempts. Default is `60000`.|
| otel.imr.export.interval | OTEL_IMR_EXPORT_INTERVAL | **DEPRECATED for removal in 1.10.0.** The interval, in milliseconds, between the start of two export attempts. Default is `60000`.|

## Customizing the OpenTelemetry SDK

Autoconfiguration exposes SPI [hooks](../autoconfigure-spi/src/main/java/io/opentelemetry/sdk/autoconfigure/spi) for customizing behavior programmatically as needed.
It's recommended to use the above configuration properties where possible, only implementing the SPI to add functionality not found in the
SDK by default.

[javadoc-image]: https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-sdk-extension-autoconfigure.svg
[javadoc-image]: https://www.javadoc.io/badge/io.opentelemetry/opentelemetry- sdk-extension-autoconfigure.svg
[javadoc-url]: https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-sdk-extension-autoconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ private static void configurePeriodicMetricReader(
SdkMeterProviderBuilder sdkMeterProviderBuilder,
MetricExporter exporter) {

Duration exportInterval = config.getDuration("otel.imr.export.interval");
Duration exportInterval = config.getDuration("otel.metric.export.interval");
if (exportInterval == null) {
exportInterval = config.getDuration("otel.imr.export.interval");
}
if (exportInterval == null) {
exportInterval = Duration.ofMinutes(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void configuresGlobal() {
System.setProperty("otel.exporter.otlp.endpoint", "https://localhost:" + server.httpsPort());
System.setProperty(
"otel.exporter.otlp.certificate", certificate.certificateFile().getAbsolutePath());
System.setProperty("otel.imr.export.interval", "1s");
System.setProperty("otel.metric.export.interval", "1s");

GlobalOpenTelemetry.get().getTracer("test").spanBuilder("test").startSpan().end();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void configuresGlobal() {
"otel.exporter.otlp.endpoint",
"https://" + canonicalHostName + ":" + server.httpsPort() + "/");
System.setProperty("otel.exporter.otlp.certificate", certificateExtension.filePath);
System.setProperty("otel.imr.export.interval", "1s");
System.setProperty("otel.metric.export.interval", "1s");

GlobalOpenTelemetry.get().getTracer("test").spanBuilder("test").startSpan().end();

Expand Down

0 comments on commit 4b7e509

Please sign in to comment.