Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 2.45 KB

README.md

File metadata and controls

51 lines (38 loc) · 2.45 KB

OpenTelemetry-Ktor Demo

OpenTelemetry provides support for Ktor with the KtorClientTracingand KtorServerTracing plugins for the Ktor client and server respectively. For the source code, see the repository on GitHub.

This project contains examples of how to use the KtorClientTracing and KtorServerTracing plugins.

You can find examples for the client plugin KtorClientTracing in the extractions folder.
And you can find examples for the server plugin KtorServerTracing in the extractions folder.

Running

Note: You need to have Docker installed and running to run the sample.

To run this sample, execute the following command from the opentelemetry directory::

./gradlew :runWithDocker

It will start a Jaeger in the docker container (Jaeger UI available on http://localhost:16686/search) and then it will start a server on http://localhost:8080/

Then, to run the client, which will send requests to a server, you can execute the following command in an opentelemetry directory:

./gradlew :client:run

Note: In this example, we use an Autoconfiguration OpenTelemetry instance, we set environment variables OTEL_METRICS_EXPORTER and OTEL_EXPORTER_OTLP_ENDPOINT in build.gradle.kts file. You can find more information about these environment variables in the OpenTelemetry documentation.

Let's check what we will see in the Jaeger UI after running the server (with Docker) and the client:

  1. We can see two our services that send opentelemetry data: opentelemetry-ktor-sample-server and opentelemetry-ktor-sample-client, and service jaeger-all-in-one, it's Jaeger tracing some of its components: img.png
  2. If you select opentelemetry-ktor-sample-server service and click on Find traces, you will see a list of traces: img.png
  3. If you click on one of those traces, you will be navigated to a screen providing detailed information about the selected trace: img.png