|
||
---|---|---|
.. | ||
src | ||
README.md | ||
build.gradle.kts |
README.md
Library Instrumentation for Ktor version 3.0 and higher
This package contains libraries to help instrument Ktor. Server and client instrumentations are supported.
Quickstart
Add these dependencies to your project
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-3.0</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
For Gradle, add to your dependencies:
implementation("io.opentelemetry.instrumentation:opentelemetry-ktor-3.0:OPENTELEMETRY_VERSION")
Usage
Initializing server instrumentation
Initialize instrumentation by installing the KtorServerTelemetry
feature. Make sure that no other
logging plugin is installed before this.
You must set the OpenTelemetry
to use with the feature.
val openTelemetry: OpenTelemetry = ...
embeddedServer(Netty, 8080) {
install(KtorServerTelemetry) {
setOpenTelemetry(openTelemetry)
}
}
Initializing client instrumentation
Initialize instrumentation by installing the KtorClientTelemetry
feature. You must set the
OpenTelemetry
to use with
the feature.
val openTelemetry: OpenTelemetry = ...
val client = HttpClient {
install(KtorClientTelemetry) {
setOpenTelemetry(openTelemetry)
}
}