Example Ktor application instrumented with OpenTracing using ktor-opentracing, using kotlin-logging for logging and kotlin-logging-opentracing-decorator to write logs to spans.
Retrieves data about earthquakes that happened today using an API from the U.S. Geological Survey.
-
Start an all-in-one Jaeger backend with in-memory storage.
docker run -d --name jaeger \ -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \ -p 5775:5775/udp \ -p 6831:6831/udp \ -p 6832:6832/udp \ -p 5778:5778 \ -p 16686:16686 \ -p 14268:14268 \ -p 14250:14250 \ -p 9411:9411 \ jaegertracing/all-in-one:1.20
-
Start the application.
./gradlew run
-
Send some requests. Other routes available are
/earthquake/biggest
and/earthquake/biggerthan/5
(where 5 is a parameter).curl localhost:8080/earthquake/latest { "location" : "21 km SSE of Karluk, Alaska", "magnitude" : 1.9, "timeGMT" : "2020-11-02 09:46:39" }
-
See traces in Jaeger.
-
Stop the Jaeger docker container.
docker ps docker stop <containerId>