opentelemetry-java/examples/http
Giovanni Liva 2d892444d1
Add http example (#695)
* Add build scripts for HTTP example

Add HTTP example

Improved naming and formatting

Add Semantic Convention to traces

Fix semantic convention

* Add Examples as OpenTelementry project

* Changed the build configuration - Examples are compiled with the main project

* Addressing comment of @carlosalberto

* Addressed the feedback of @bogdandrutu

* Removed InMemory exporter. Example as standalone project.

* Remove examples from main build

* Making the exporter private and static

Change visibility of attributes

* Update HTTP example README

* Apply java format

Co-authored-by: Inseo Kim <sano307@naver.com>
2020-03-24 09:08:52 -07:00
..
gradle/wrapper Add http example (#695) 2020-03-24 09:08:52 -07:00
src/main/java/io/opentelemetry/example/http Add http example (#695) 2020-03-24 09:08:52 -07:00
README.md Add http example (#695) 2020-03-24 09:08:52 -07:00
build.gradle Add http example (#695) 2020-03-24 09:08:52 -07:00
gradlew Add http example (#695) 2020-03-24 09:08:52 -07:00
gradlew.bat Add http example (#695) 2020-03-24 09:08:52 -07:00
settings.gradle Add http example (#695) 2020-03-24 09:08:52 -07:00

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-example-http-all-0.2.0.jar io.opentelemetry.example.http.HttpServer

3 - Start the Client

java -cp ./build/libs/opentelemetry-example-http-all-0.2.0.jar io.opentelemetry.example.http.HttpClient