Skip to content

Commit

Permalink
Mention OTEL_METRIC_EXPORT_INTERVAL in Java manual instrumentation pa…
Browse files Browse the repository at this point in the history
…ge. (#3786)
  • Loading branch information
eplusx authored Feb 14, 2024
1 parent 3f52ad5 commit 85a6e66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 10 additions & 3 deletions content/en/docs/languages/java/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,18 @@ number of ways, the steps below use environment variables.
export JAVA_TOOL_OPTIONS="-javaagent:PATH/TO/opentelemetry-javaagent.jar" \
OTEL_TRACES_EXPORTER=logging \
OTEL_METRICS_EXPORTER=logging \
OTEL_LOGS_EXPORTER=logging
OTEL_LOGS_EXPORTER=logging \
OTEL_METRIC_EXPORT_INTERVAL=15000
```

{{% alert title="Important" color="warning" %}}Replace `PATH/TO` above, with
your path to the JAR.{{% /alert %}}
{{% alert title="Important" color="warning" %}}

- Replace `PATH/TO` above, with your path to the JAR.
- Set `OTEL_METRIC_EXPORT_INTERVAL` to a value well below the default, as we
illustrate above, **only during testing** to help you more quickly ensure
that metrics are properly generated.

{{% /alert %}}

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

Expand Down
10 changes: 10 additions & 0 deletions content/en/docs/languages/java/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,17 @@ OTEL_SERVICE_NAME=dice-server \
OTEL_TRACES_EXPORTER=logging \
OTEL_METRICS_EXPORTER=logging \
OTEL_LOGS_EXPORTER=logging \
OTEL_METRIC_EXPORT_INTERVAL=15000 \
java -jar ./build/libs/java-simple.jar
```

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

Note that `OTEL_METRIC_EXPORT_INTERVAL=15000` (milliseconds) is a temporary
setting to test that your metrics are properly generated. Remember to remove the
setting once you are done testing. The default is 60000 milliseconds.

#### Manual Configuration

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

If you use the `console` or `logging` exporter for metrics, consider temporarily
setting `OTEL_METRIC_EXPORT_INTERVAL` to a small value like `15000`
(milliseconds) while testing that your metrics are properly recorded. Remember
to remove the setting once you are done testing.

It's also possible to set up the propagators via the `OTEL_PROPAGATORS`
environment variable, like for example using the `tracecontext` value to use
[W3C Trace Context](https://www.w3.org/TR/trace-context/).
Expand Down

0 comments on commit 85a6e66

Please sign in to comment.