/elastic-otel-java

Primary LanguageJavaApache License 2.0Apache-2.0

Elastic Distribution of OpenTelemetry Java

Snapshot status Release status

The Elastic Distribution of OpenTelemetry Java (EDOT Java) is a customized version of the OpenTelemetry Java agent. Use EDOT Java to start the OpenTelemetry SDK with your Java application, and automatically capture tracing data, performance metrics, and logs. Traces, metrics, and logs can be sent to any OpenTelemetry Protocol (OTLP) collector you choose.

With EDOT Java you have access to all the features of the OpenTelemetry Java agent plus:

  • Access to SDK improvements and bug fixes contributed by the Elastic team before the changes are available upstream in OpenTelemetry repositories.
  • Access to optional features that can enhance OpenTelemetry data that is being sent to Elastic (for example, inferred spans and span stacktrace).

Ready to try out EDOT Java? Follow the step-by-step instructions in Get started.

We welcome your feedback! You can reach us by opening a GitHub issue or starting a discussion thread on the Elastic Discuss forum.

Download

Latest release: Maven Central

Latest snapshot: Sonatype Nexus

Run

Use the -javaagent: JVM argument with the path to agent jar.

java -javaagent:/path/to/agent.jar \
-jar myapp.jar

Read the docs

Build and Test

Execute ./gradlew assemble, the agent binary will be in ./agent/build/libs/elastic-otel-javaagent-${VERSION}.jar where ${VERSION} is the current project version set in version.properties.

You can run the tests locally using ./gradlew test. You can optionally specify the

  • Java Version to test on, e.g. -PtestJavaVersion=8
  • Java implementation to run on (hotspot or openJ9): -PtestJavaVM=openj9

You don't need to have a corresponding JVM installed, gradle automatically will download a matching one.

Features

Resource attributes

The agent enables the following resource attributes providers from opentelemetry-java-contrib

The attributes for cloud providers are captured asynchronously to prevent application startup overhead due to calling an internal metadata API.

Inferred spans

Set OTEL_INFERRED_SPANS_ENABLED=true to enable.

See inferred spans for more details

Span stacktrace

The agent captures the stacktraces of spans to help identify code paths that triggered them.

The stacktrace is stored in the code.stacktrace attribute.

The minimum span duration can be configured with elastic.otel.java.span-stacktrace.min.duration (defaults to 5ms).

Implementation has been contributed upstream in the opentelemetry-java-contrib repository, in the span-stacktrace folder.

Runtime metrics

Experimental runtime metrics are enabled by default. Set otel.instrumentation.runtime-telemetry.emit-experimental-telemetry to false to disable them.

License

The Elastic Distribution of OpenTelemetry Java is licensed under Apache License, Version 2.0.