OpenTelemetry OpenTelemetry instrumentation Auto-Instrumentation for Java with Java Agent
Open source

Automatic Instrumentation of Java applications with the OpenTelemetry Java Agent

Java applications can be instrumented without changing the source code1.

Getting Started

Download the latest version of the OpenTelemetry Java Auto Instrumentation Agent.

Enable the instrumentation agent using the -javaagent flag to the JVM.

export OTEL_SERVICE_NAME="demo"
export OTEL_RESOURCE_ATTRIBUTES="service.version=1.1,"
java -javaagent:path/to/opentelemetry-javaagent.jar \
     -jar myapp.jar

The application will send data to the Grafana Agent. Please follow the Grafana Agent configuration for OpenTelemetry guide.

  • If the grafana agent is not running locally with the default gRPC endpoint (localhost:4317), then you need to set the endpoint (details).
  • OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES are not required, but very helpful - please replace demo, 1.1, and pod2 as explained here. Note that service name can also be set in OTEL_RESOURCE_ATTRIBUTES using the key service_name (ex. service_name=demo).

  1. The Java agent dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks. ↩︎