opentelemetry-java-instrume.../instrumentation/ktor/ktor-1.0/library
Lauri Tulmin 76c2d2d8f3
Add ktor 3 instrumentation (#12562)
2024-11-11 13:03:11 +02:00
..
src Update the default expected exception in server tests (#12555) 2024-11-02 17:42:03 +02:00
README.md Add ktor 3 instrumentation (#12562) 2024-11-11 13:03:11 +02:00
build.gradle.kts Fix deprecated kotlin compiler configuration (#11501) 2024-06-01 13:39:38 +03:00

README.md

Library Instrumentation for Ktor version 1.x

This package contains libraries to help instrument Ktor. Currently, only server instrumentation is 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-1.0</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>
</dependencies>

For Gradle, add to your dependencies:

implementation("io.opentelemetry.instrumentation:opentelemetry-ktor-1.0:OPENTELEMETRY_VERSION")

Usage

Initialize instrumentation by installing the KtorServerTracing feature. You must set the OpenTelemetry to use with the feature.

OpenTelemetry openTelemetry = ...

embeddedServer(Netty, 8080) {
  install(KtorServerTracing) {
    setOpenTelemetry(openTelemetry)
  }
}