Skip to content

An implementation of the OpenTelemetry specification as a Kotlin Multiplatform Library, developed by embrace.io

License

Notifications You must be signed in to change notification settings

embrace-io/opentelemetry-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenTelemetry Kotlin

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.

Supported targets

The following targets are supported:

  • Android (API >=21)
  • JVM (JDK >= 8)

Support for iOS and other platforms is planned for the future.

Supported OTel APIs

  • Tracing
  • Logging

Getting Started

  1. 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>")
}
  1. Wrap your existing OTel Java instance:
val otelJava = io.opentelemetry.sdk.OpenTelemetrySdk.builder().build()
val otelKotlin = OpenTelemetrySdk(otelJava)
  1. Use the Kotlin API instead of the Java API in your app

Example usage

Tracing API

val tracer = otelKotlin.tracerProvider.getTracer(
    name = "kotlin-example-app",
    version = "0.1.0"
)
tracer.createSpan("my_span")

Logging API

val logger = otelKotlin.loggerProvider.getLogger("my_logger")
logger.log("Hello, World!")

Example Apps

Example usage of the library can be found here.

Feedback/bugs

Got feedback or found a bug? Please open a GitHub issue or contact [email protected] and we'll get back to you.

About

An implementation of the OpenTelemetry specification as a Kotlin Multiplatform Library, developed by embrace.io

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages