opentelemetry-java-instrume.../instrumentation/ktor/ktor-2.0/library
Trask Stalnaker 71b3e3e027
Library doc cleanup (#6948)
Related to #6947, but just cleans up the library module doc that already
existed (mostly for uniformity). Does not introduce any new doc.
2022-10-24 10:26:21 -07:00
..
src Capture net.host.name for netty (#6892) 2022-10-19 09:21:50 -07:00
README.md Library doc cleanup (#6948) 2022-10-24 10:26:21 -07:00
build.gradle.kts Add library instrumentation for ktor 2 (#5797) 2022-04-11 13:05:00 +03:00

README.md

Library Instrumentation for Ktor version 2.0 and higher

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-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")

Usage

Initializing server instrumentation

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

OpenTelemetry openTelemetry = initializeOpenTelemetryForMe()

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