Menu
Open source
Automatic Instrumentation of Java applications with the OpenTelemetry Java Agent
Java applications can be instrumented without changing the source code1.
- Supports Java 8+
- Supports a large number libraries, frameworks and application servers
- Project Website
- If you are using Spring Boot 3.x, we recommend to use the Grafana OpenTelemetry Starter.
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,service.instance.id=pod2"
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
andOTEL_RESOURCE_ATTRIBUTES
are not required, but very helpful - please replacedemo
,1.1
, andpod2
as explained here. Note that service name can also be set inOTEL_RESOURCE_ATTRIBUTES
using the keyservice_name
(ex.service_name=demo
).
The Java agent dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks. ↩︎