Java
Learn how to instrument your Java applications with OpenTelemetry and send data to PlayerZero.
OpenTelemetry for Java
OpenTelemetry provides a powerful and mature set of tools to instrument Java applications. With support for auto-instrumentation, manual span creation, and OTLP exporters, you can quickly start collecting traces, logs, and metrics from your Java services.
Installation
To get started, you’ll need to add the OpenTelemetry Java libraries to your project.
You can use Maven, Gradle, or your preferred build tool.
Refer to the official installation guide:
👉 OpenTelemetry Java Getting Started
Auto-Instrumentation
Auto-instrumentation lets you automatically trace common libraries such as HTTP clients, database drivers, and more without needing to modify your code. OpenTelemetry provides auto-instrumentation libraries for many popular languages, making it fast to get started with tracing.
For Java, you can use the OpenTelemetry Java Agent to auto-instrument your application without code changes.
- Download the agent jar.
- Start your application with the
-javaagent
JVM argument pointing to the downloaded jar.
Learn more:
👉 Java Auto-Instrumentation Setup
Manual Instrumentation
Manual instrumentation gives you full control over your traces, allowing you to create spans wherever needed. You can customize span names, attributes, and relationships to capture the most important parts of your application’s flow.
If you need more control, you can manually create spans inside your Java codebase using the OpenTelemetry API and SDK.
Learn more:
👉 Java Manual Instrumentation Guide
Exporters
Once your application is instrumented, you need to export telemetry data. PlayerZero supports the OpenTelemetry Protocol (OTLP) over HTTP. You can configure your OpenTelemetry SDK to export traces, logs, and metrics to PlayerZero’s endpoint by setting the endpoint URL and API token.
For Java, you typically configure exporters via environment variables or code configuration.
Essential properties to set:
OTEL_EXPORTER_OTLP_ENDPOINT=https://sdk.playerzero.app/otlp
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <your-playerzero-token>
OTEL_TRACES_EXPORTER=otlp
OTEL_LOGS_EXPORTER=otlp
OTEL_METRICS_EXPORTER=otlp
Official reference:
Optional: Using a Collector
Once your application is instrumented, you need to export telemetry data. PlayerZero supports the OpenTelemetry Protocol (OTLP) over HTTP. You can configure your OpenTelemetry SDK to export traces, logs, and metrics to PlayerZero’s endpoint by setting the endpoint URL and API token.
If you want to process or route telemetry centrally, you can forward your Java application’s telemetry to a collector before sending it to PlayerZero.
Helpful Links
For detailed language-specific instrumentation examples and full OpenTelemetry documentation, refer to the links below.
Was this page helpful?