Skip to content

Commit 85a6e66

Browse files
authored
Mention OTEL_METRIC_EXPORT_INTERVAL in Java manual instrumentation page. (#3786)
1 parent 3f52ad5 commit 85a6e66

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

content/en/docs/languages/java/getting-started.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,18 @@ number of ways, the steps below use environment variables.
144144
export JAVA_TOOL_OPTIONS="-javaagent:PATH/TO/opentelemetry-javaagent.jar" \
145145
OTEL_TRACES_EXPORTER=logging \
146146
OTEL_METRICS_EXPORTER=logging \
147-
OTEL_LOGS_EXPORTER=logging
147+
OTEL_LOGS_EXPORTER=logging \
148+
OTEL_METRIC_EXPORT_INTERVAL=15000
148149
```
149150

150-
{{% alert title="Important" color="warning" %}}Replace `PATH/TO` above, with
151-
your path to the JAR.{{% /alert %}}
151+
{{% alert title="Important" color="warning" %}}
152+
153+
- Replace `PATH/TO` above, with your path to the JAR.
154+
- Set `OTEL_METRIC_EXPORT_INTERVAL` to a value well below the default, as we
155+
illustrate above, **only during testing** to help you more quickly ensure
156+
that metrics are properly generated.
157+
158+
{{% /alert %}}
152159

153160
3. Run your **application** once again:
154161

content/en/docs/languages/java/instrumentation.md

+10
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,17 @@ OTEL_SERVICE_NAME=dice-server \
419419
OTEL_TRACES_EXPORTER=logging \
420420
OTEL_METRICS_EXPORTER=logging \
421421
OTEL_LOGS_EXPORTER=logging \
422+
OTEL_METRIC_EXPORT_INTERVAL=15000 \
422423
java -jar ./build/libs/java-simple.jar
423424
```
424425

425426
This basic setup has no effect on your app yet. You need to add code for
426427
[traces](#traces), [metrics](#metrics), and/or [logs](#logs).
427428

429+
Note that `OTEL_METRIC_EXPORT_INTERVAL=15000` (milliseconds) is a temporary
430+
setting to test that your metrics are properly generated. Remember to remove the
431+
setting once you are done testing. The default is 60000 milliseconds.
432+
428433
#### Manual Configuration
429434

430435
`OpenTelemetrySdk.builder()` returns an instance of `OpenTelemetrySdkBuilder`,
@@ -1547,6 +1552,11 @@ example `OTEL_TRACES_EXPORTER=jaeger` configures your application to use the
15471552
Jaeger exporter. The corresponding Jaeger exporter library has to be provided in
15481553
the classpath of the application as well.
15491554

1555+
If you use the `console` or `logging` exporter for metrics, consider temporarily
1556+
setting `OTEL_METRIC_EXPORT_INTERVAL` to a small value like `15000`
1557+
(milliseconds) while testing that your metrics are properly recorded. Remember
1558+
to remove the setting once you are done testing.
1559+
15501560
It's also possible to set up the propagators via the `OTEL_PROPAGATORS`
15511561
environment variable, like for example using the `tracecontext` value to use
15521562
[W3C Trace Context](https://www.w3.org/TR/trace-context/).

0 commit comments

Comments
 (0)