The JVM backend

otel4s-oteljava is the JVM backend for otel4s. It implements the otel4s APIs on top of OpenTelemetry Java.

Use it when you want otel4s instrumentation to run against the OpenTelemetry Java SDK and ecosystem.

When to use otel4s-oteljava

This backend is usually the right fit when you are building a JVM application and you want:

otel4s-oteljava is JVM-only. If you need a backend for Scala.js or Scala Native, use the separate otel4s-sdk project instead.

Two ways to access the SDK

Most JVM applications use one of these entry points:

API Use it when What it does
OtelJava.autoConfigured your application is responsible for creating the SDK creates an isolated, non-global SDK instance from OpenTelemetry Java autoconfiguration
OtelJava.global the SDK is already configured elsewhere reads the current process-wide OpenTelemetry instance

The difference matters because these paths have different ownership and interoperability rules.

OtelJava.autoConfigured

Use OtelJava.autoConfigured when your application owns SDK creation.

This is the common path when:

OtelJava.autoConfigured creates an isolated instance. If the same process already has a global SDK that other code relies on, creating a separate isolated instance can make telemetry behavior harder to reason about.

For the setup steps, use Set up otel4s in a JVM application.

OtelJava.global

Use OtelJava.global when SDK creation happens elsewhere and otel4s needs to join that existing setup.

This is the common path when:

OtelJava.global does not configure an SDK. It only reads the global instance that already exists.

For the setup steps, use Use the global OpenTelemetry instance.

Some JVM-specific modules are useful only in particular situations:

If you are using the otel4s Java agent distribution, also see:

Next steps