An implementation of the OpenTelemetry specification as a Kotlin Multiplatform Library, developed by embrace.io.
Currently this API is a facade for the OpenTelemetry Java SDK. In the near future this library will provide its own KMP implementation of the OpenTelemetry specification.
The following targets are supported:
- Android (API >=21)
- JVM (JDK >= 8)
Support for iOS and other platforms is planned for the future.
- Tracing
- Logging
- Add the following dependencies to your Android/Java project:
dependencies {
implementation("io.embrace.opentelemetry.kotlin:opentelemetry-kotlin-api:<latest-version>")
implementation("io.embrace.opentelemetry.kotlin:opentelemetry-kotlin-api-ext:<latest-version>")
implementation("io.embrace.opentelemetry.kotlin:compat-kotlin-to-official:<latest-version>")
}
- Wrap your existing OTel Java instance:
val otelJava = io.opentelemetry.sdk.OpenTelemetrySdk.builder().build()
val otelKotlin = OpenTelemetrySdk(otelJava)
- Use the Kotlin API instead of the Java API in your app
val tracer = otelKotlin.tracerProvider.getTracer(
name = "kotlin-example-app",
version = "0.1.0"
)
tracer.createSpan("my_span")
val logger = otelKotlin.loggerProvider.getLogger("my_logger")
logger.log("Hello, World!")
Example usage of the library can be found here.
Got feedback or found a bug? Please open a GitHub issue or contact [email protected] and we'll get back to you.