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 latest opentelemetry-javaagent.jar from the OpenTelemetry Java instrumentation releases and attach it to your JVM startup:
java -javaagent:path/to/opentelemetry-javaagent.jar -jar myapp.jar
Alternatively, if you are using 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. Replace YOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.
VariableValue
OTEL_EXPORTER_OTLP_ENDPOINThttps://app.trace0hq.com/api
OTEL_EXPORTER_OTLP_HEADERSX-API-KEY=YOUR_TRACE0_ENV_API_KEY
Alternatively, you can set these in a YAML file using declarative configuration.

3. Deploy Service

Deploy your service and watch traces, metrics, and logs appear in the Trace0 dashboard within seconds.

Example Service

See our Java EC2 example app for a working service you can deploy to your AWS account.