Skip to content

Commit 98b7ffc

Browse files
committed
Fix README
1 parent 110d849 commit 98b7ffc

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

opentelemetry/README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
11
# OpenTelemetry-Ktor Demo
22

33
## Running
4+
5+
**Note:** You need to have [Docker](https://www.docker.com/) installed and running to run the sample.
6+
47
To run a sample, first, execute the following command in an `opentelemetry` directory:
8+
59
```bash
610
./gradlew :runWithDocker
711
```
12+
813
It will start a `Jaeger` in the docker container (`Jaeger UI` available on http://localhost:16686/search) and
914
then it will start a `server` on http://localhost:8080/
1015

11-
Then, to run the client, which will send requests to a server, you can execute the following command in an `opentelemetry` directory:
16+
Then, to run the client, which will send requests to a server, you can execute the following command in
17+
an `opentelemetry` directory:
18+
1219
```bash
1320
./gradlew :client:run
1421
```
1522

16-
[OpenTelemetry](https://opentelemetry.io/) has support for `Ktor`, you can find source code [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/ktor).
23+
[OpenTelemetry](https://opentelemetry.io/) has support for `Ktor`, you can find source
24+
code [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/ktor).
1725
It contains plugins for client and server: `KtorClientTracing` and `KtorServerTracing`.
1826

27+
**Note:** In this example, we use
28+
an [Autoconfiguration OpenTelemetry instance](https://opentelemetry.io/docs/languages/java/instrumentation/#automatic-configuration),
29+
we set environment variables `OTEL_METRICS_EXPORTER` and `OTEL_EXPORTER_OTLP_ENDPOINT`
30+
in [build.gradle.kts](./build.gradle.kts) file.
31+
You can find more information about these environment variables
32+
in the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/sdk-configuration/).
33+
1934
## Motivation
35+
2036
This project contains extension functions for plugins that allow you to write code in the Ktor DSL style. \
2137
For example, you can rewrite the next code:
38+
2239
```kotlin
2340
install(KtorServerTracing) {
2441
...
@@ -38,24 +55,32 @@ install(KtorServerTracing) {
3855
...
3956
}
4057
```
58+
4159
To a more readable for `Ktor` style:
60+
4261
```kotlin
4362
install(KtorServerTracing) {
4463
...
4564
attributeExtractor {
4665
onEnd {
4766
attributes.put("end-time", Instant.now().toEpochMilli())
4867
}
49-
}
68+
}
5069
...
5170
}
5271
```
53-
You can find all extensions for the client plugin `KtorClientTracing` in the [extractions](./client/src/main/kotlin/opentelemetry/ktor/example/plugins/opentelemetry/extractions/) folder. \
54-
And you can find all extensions for the server plugin `KtorServerTracing` in the [extractions](./server/src/main/kotlin/opentelemetry/ktor/example/plugins/opentelemetry/extractions/) folder.
72+
73+
You can find all extensions for the client plugin `KtorClientTracing` in
74+
the [extractions](./client/src/main/kotlin/opentelemetry/ktor/example/plugins/opentelemetry/extractions/) folder. \
75+
And you can find all extensions for the server plugin `KtorServerTracing` in
76+
the [extractions](./server/src/main/kotlin/opentelemetry/ktor/example/plugins/opentelemetry/extractions/) folder.
5577

5678
## Examples
79+
5780
Let's see what we will see in the `Jaeger UI` after running the server (with Docker) and client:
58-
1. We can see two services that send opentelemetry data: `opentelemetry-ktor-sample-server` and `opentelemetry-ktor-sample-client`:
81+
82+
1. We can see two services that send opentelemetry data: `opentelemetry-ktor-sample-server`
83+
and `opentelemetry-ktor-sample-client`:
5984
![img.png](images/1.png)
6085
2. If we choose `opentelemetry-ktor-sample-server` service, we will see the next traces:
6186
![img.png](images/2.png)

0 commit comments

Comments
 (0)