* Call initTracer just once at beginning of main. This fixes a bug where each time a new HttpClient is instantiated, it adds a new SpanExporter to the global OpenTelemetry SDK instance. * s/InitTracer/InitTracerSdk/ |
||
|---|---|---|
| .. | ||
| src/main/java/io/opentelemetry/example/http | ||
| README.md | ||
| build.gradle | ||
README.md
HTTP Example
Note: This is an advanced scenario useful for people that want to manually instrument their own code.
This is a simple example that demonstrates how to use the OpenTelemetry SDK to manually instrument a simple HTTP based Client/Server application. The example creates the Root Span on the client and sends the context over the HTTP request. On the server side, the example shows how to extract the context and create a Child Span with attached a Span Event.
How to run
Prerequisites
- Java 1.8.231
- Be on the project root folder
1 - Compile
../gradlew fatJar
2 - Start the Server
java -cp ./build/libs/opentelemetry-examples-http-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.http.HttpServer
3 - Start the Client
java -cp ./build/libs/opentelemetry-examples-http-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.http.HttpClient