This package contains libraries to help instrument Ktor. Server and client instrumentations are supported.
Replace OPENTELEMETRY_VERSION
with the latest
release.
For Maven, add to your pom.xml
dependencies:
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-ktor-2.0</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
For Gradle, add to your dependencies:
implementation("io.opentelemetry.instrumentation:opentelemetry-ktor-2.0:OPENTELEMETRY_VERSION")
Initialize instrumentation by installing the KtorServerTracing
feature. You must set the OpenTelemetry
to use with
the feature.
val openTelemetry: OpenTelemetry = ...
embeddedServer(Netty, 8080) {
install(KtorServerTracing) {
setOpenTelemetry(openTelemetry)
}
}
Initialize instrumentation by installing the KtorClientTracing
feature. You must set the OpenTelemetry
to use with
the feature.
val openTelemetry: OpenTelemetry = ...
val client = HttpClient {
install(KtorClientTracing) {
setOpenTelemetry(openTelemetry)
}
}