Skip to main content

Module structure

otel4s is designed with modularity in mind. The project is organized into distinct high-level modules, each serving specific purposes and functionalities. These modules are: otel4s-core, otel4s-sdk, and otel4s-oteljava. The primary motivation behind this modular architecture is to keep the classpath small.

High-level modules

1. otel4s-core

Defines the interfaces: Tracer, Meter, and others. It also offers no-op implementations. Use this module when:
  • You’re developing a library and want to add telemetry instrumentation
  • You want minimal dependencies and the smallest classpath
  • You want users to choose their own backend implementation

2. otel4s-sdk

The implementation of the OpenTelemetry specification written purely in Scala. Available for all platforms: JVM, Scala Native, and Scala.js. Use this module when:
  • You need cross-platform support (Scala.js or Scala Native)
  • You prefer a pure Scala implementation
  • You’re willing to accept some experimental features
The SDK backend remains experimental and some functionality may be lacking. Memory overhead may be noticeable compared to the Java SDK backend.

3. otel4s-oteljava

The implementation of otel4s-core interfaces using OpenTelemetry Java under the hood. Use this module when:
  • You’re developing a JVM application and want to export telemetry
  • You want production-ready, well-tested telemetry
  • You want access to the extensive Java instrumentation ecosystem
  • You need low memory overhead

High-level module structure

Each high-level module has several submodules:
  1. {x}-common - Shared code used by {x}-trace and {x}-metrics
  2. {x}-trace - Tracing-specific code
  3. {x}-metrics - Metrics-specific code
  4. {x} - The high-level module itself, aggregating all of the above
The current structure of the modules:

Which module do I need?

Let’s look at common scenarios:
Use otel4s-core-trace
build.sbt
libraryDependencies += "org.typelevel" %% "otel4s-core-trace" % "0.15.0"
This gives you access to the Tracer interface with minimal dependencies.
Use otel4s-core
build.sbt
libraryDependencies += "org.typelevel" %% "otel4s-core" % "0.15.0"
This includes both Tracer and Meter interfaces.
Use otel4s-oteljava (recommended)
build.sbt
libraryDependencies ++= Seq(
  "org.typelevel" %% "otel4s-oteljava" % "0.15.0",
  "io.opentelemetry" % "opentelemetry-exporter-otlp" % "1.59.0" % Runtime,
  "io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % "1.59.0" % Runtime
)
This gives you a production-ready backend with low overhead and extensive integrations.
Use otel4s-sdk
build.sbt
libraryDependencies += "org.typelevel" %% "otel4s-sdk" % "0.15.0"
The SDK backend is experimental. Some features may be missing or have higher memory overhead.

Module comparison

Featureotel4s-coreotel4s-sdkotel4s-oteljava
PurposeInterfaces onlyPure Scala implJava SDK wrapper
JVM
Scala.js
Scala Native
Production readyN/A⚠️ Experimental
Memory overheadMinimalHigherLow
DependenciesMinimalMediumMany
Use caseLibrariesCross-platform appsJVM applications

Next steps

Quickstart

Get started with otel4s in your application

OTel Java backend

Learn about the recommended backend for JVM applications

SDK backend

Explore the pure Scala implementation

Core concepts

Understand tracing, metrics, and context propagation

Build docs developers (and LLMs) love