This guide covers Java applications running on ECS, EC2, Kubernetes, or any container/VM environment. For Java on AWS Lambda, see the Java Lambda guide.
1. Install the OpenTelemetry Java Agent
Download the latestopentelemetry-javaagent.jar from the OpenTelemetry Java instrumentation releases and attach it to your JVM startup:
Gradle, you can use the Gradle Javaagent Plugin to attach the agent to your application.
For full configuration options, see the official OpenTelemetry Java Agent docs.
2. Set Environment Variables
Add the following environment variables to your application. ReplaceYOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.
| Variable | Value |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | https://app.trace0hq.com/api |
OTEL_EXPORTER_OTLP_HEADERS | X-API-KEY=YOUR_TRACE0_ENV_API_KEY |