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
3. otel4s-oteljava
The implementation ofotel4s-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:{x}-common- Shared code used by{x}-traceand{x}-metrics{x}-trace- Tracing-specific code{x}-metrics- Metrics-specific code{x}- The high-level module itself, aggregating all of the above
Which module do I need?
Let’s look at common scenarios:I'm developing a library and only need tracing
I'm developing a library and only need tracing
Use This gives you access to the
otel4s-core-tracebuild.sbt
Tracer interface with minimal dependencies.I'm developing a library and need both tracing and metrics
I'm developing a library and need both tracing and metrics
Use This includes both
otel4s-corebuild.sbt
Tracer and Meter interfaces.I'm developing an application and want to export telemetry
I'm developing an application and want to export telemetry
Use This gives you a production-ready backend with low overhead and extensive integrations.
otel4s-oteljava (recommended)build.sbt
I need Scala.js or Scala Native support
I need Scala.js or Scala Native support
Use
otel4s-sdkbuild.sbt
Module comparison
| Feature | otel4s-core | otel4s-sdk | otel4s-oteljava |
|---|---|---|---|
| Purpose | Interfaces only | Pure Scala impl | Java SDK wrapper |
| JVM | ✅ | ✅ | ✅ |
| Scala.js | ✅ | ✅ | ❌ |
| Scala Native | ✅ | ✅ | ❌ |
| Production ready | N/A | ⚠️ Experimental | ✅ |
| Memory overhead | Minimal | Higher | Low |
| Dependencies | Minimal | Medium | Many |
| Use case | Libraries | Cross-platform apps | JVM 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