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:<latest-version>")
implementation("io.embrace.opentelemetry.kotlin:opentelemetry-kotlin-compat:<latest-version>")
}
- Wrap your existing OTel Java instance:
val otelJava = io.opentelemetry.sdk.OpenTelemetrySdk.builder().build()
val otelKotlin = OpenTelemetryInstance.compatWithOtelJava(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 support@embrace.io and we'll get back to you.
Every day, a snapshot version is published to the maven snapshots repository. You can check the current snapshot version in gradle.properties. To use a snapshot version in your app, you need to add the Central Portal snapshot repository, like this:
repositories {
...
maven {
name = "Central Portal Snapshots"
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
content {
includeGroup("io.embrace")
}
}
...
}