Integrations
Java
Instrument your Java applications to send traces to Kopai using the OpenTelemetry Java agent.
Java Agent (Recommended)
Section titled “Java Agent (Recommended)”The OpenTelemetry Java agent provides zero-code instrumentation - no code changes required.
Download the Agent
Section titled “Download the Agent”curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jarRunning Your Application
Section titled “Running Your Application”Set environment variables and run with the agent:
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp-http.kopai.app"export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer YOUR_TOKEN"export OTEL_SERVICE_NAME="my-java-service"
java -javaagent:opentelemetry-javaagent.jar -jar your-app.jar| Variable | Description |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT |
Kopai OTLP endpoint |
OTEL_EXPORTER_OTLP_HEADERS |
Auth header with your backend token |
OTEL_SERVICE_NAME |
Name shown in Kopai UI |
Auto-Instrumentation
Section titled “Auto-Instrumentation”The Java agent automatically instruments:
- HTTP - Spring MVC, JAX-RS, Servlet, Netty, OkHttp
- Databases - JDBC, Hibernate, MongoDB, Redis, Cassandra
- Messaging - Kafka, RabbitMQ, JMS
- Frameworks - Spring Boot, Quarkus, Micronaut, Vert.x
- Runtime - JVM metrics, garbage collection, thread pools
See the full list of supported libraries.
Working Example
Section titled “Working Example”For a complete working example:
Troubleshooting
Section titled “Troubleshooting”No traces appearing
Section titled “No traces appearing”- Verify the agent is loaded: look for
[otel.javaagent]in startup logs - Check
OTEL_EXPORTER_OTLP_ENDPOINTis set correctly - Verify token in
OTEL_EXPORTER_OTLP_HEADERS
Agent not attaching
Section titled “Agent not attaching”- Ensure
-javaagentflag comes before-jar - Check Java version: agent requires Java 8+
Debug logging
Section titled “Debug logging”Enable agent debug logs:
export OTEL_JAVAAGENT_DEBUG=true