Skip to content

Commit

Permalink
Merge pull request #289 from logzio/kafka-tracing-otel-instrumentation
Browse files Browse the repository at this point in the history
Update steps to Kafka tracing OpenTelemetry instrumentation
  • Loading branch information
nico-shishkin authored Dec 6, 2023
2 parents 0c78255 + 6f3801a commit bd38c8a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion docs/shipping/Code/java-traces-with-kafka-using-opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ If you produce and consume Kafka topics/messages from different applications, th


```shell
java -javaagent:<path/to>/opentelemetry-javaagent-all.jar \
java -javaagent:<path/to>/opentelemetry-javaagent.jar \
-Dotel.traces.exporter=otlp \
-Dotel.metrics.exporter=none \
-Dotel.resource.attributes=service.name=<YOUR-SERVICE-NAME> \
Expand All @@ -76,6 +76,34 @@ java -javaagent:<path/to>/opentelemetry-javaagent-all.jar \
* Replace `<path/to>` with the path to the directory where you downloaded the agent.
* Replace `<YOUR-SERVICE-NAME>` with the name of your tracing service defined earlier.

### Kafka OpenTelemery Java Applications
There are some pre-written Java applications that insturment Kafka clients with OpenTelemetry.

You can download the relevant applications from the [kafka-opentelemetry GitHub repository](https://github.com/ppatierno/kafka-opentelemetry/tree/main) and compile the JAR file using the `mvn install` command.

#### Kafka Consumer Example
Run the OpenTelemetry Java Agent insturmated with the [Kafka consumer application](https://github.com/ppatierno/kafka-opentelemetry/tree/main/kafka-consumer-agent) in the following way:
```shell
java -javaagent:<path/to>/opentelemetry-javaagent.jar \
-Dotel.traces.exporter=otlp \
-Dotel.metrics.exporter=none \
-Dotel.resource.attributes=service.name=<YOUR-CONSUMER-NAME> \
-Dotel.exporter.otlp.endpoint=http://localhost:4317 \
-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true \
-jar kafka-consumer-agent/target/kafka-consumer-agent-1.0-SNAPSHOT-jar-with-dependencies.jar
```

#### Kafka Producer Example
Run the OpenTelemetry Java Agent insturmated with the [Kafka producer application](https://github.com/ppatierno/kafka-opentelemetry/tree/main/kafka-producer-agent) in the following way:
```shell
java -javaagent:<path/to>/opentelemetry-javaagent.jar \
-Dotel.traces.exporter=otlp \
-Dotel.metrics.exporter=none \
-Dotel.resource.attributes=service.name=<YOUR-PRODUCER-NAME> \
-Dotel.exporter.otlp.endpoint=http://localhost:4317 \
-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true \
-jar kafka-producer-agent/target/kafka-producer-agent-1.0-SNAPSHOT-jar-with-dependencies.jar
```

### Check Logz.io for your traces

Expand Down

0 comments on commit bd38c8a

Please sign in to comment.