| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a basic client/server for playing with OpenTelemetry in Java and learning all of the basic API calls. The code is very simple and heavily commented; it makes for a good source if you are looking for a place to copypasta OpenTelemetry patterns from.
Handy links:
Define your Lightstep Access Token prior to running the app. You can find your access token under "settings" in the Lightstep UI.
export LS_ACCESS_TOKEN=<YOUR ACCESS TOKEN GOES HERE>Build:
makeRun the server and wait for it to be ready:
make run-serverRun the client to perform a few requests:
make run-clientThe code in this repo shows how to decorate a simple Servlet with OpenTelemetry calls to teach you how to manually instrument your code. But if you are using a supported framework like spring, you get a lot of auto-instrumentation out of the box.
Let's take (Pet Clinic)[https://github.com/spring-projects/spring-petclinic], an example Spring app, and add OpenTelemetry to it.
First, set up Petclinic:
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
./mvnw packageThen, fetch the Lightstep Launcher for Java. The Launcher is a distro of the OpenTelemetry Java Agent that is pre-configured to talk to Lightstep:
curl -L -O https://github.com/lightstep/otel-launcher-java/releases/download/0.14.0/lightstep-opentelemetry-javaagent-0.14.0.jarUse env vars to add your Lightstep access token and to correctly name your service.
export LS_ACCESS_TOKEN=<YOUR ACCESS TOKEN GOES HERE>
export LS_SERVICE_NAME=petclinicWith that, you're ready to start petclinic locally, with the Launcher attached as a Java agent.
java -javaagent:lightstep-opentelemetry-javaagent-0.14.0.jar -jar target/*.jarAfter petclinic starts, go to http://localhost:8080/ and interact with it a bit.
After you've messed around a bit, have a look at the data by clicking on the Explorer in Lightstep. You'll see a number of spans; click on any of them to see a trace.
Notice how much information is automatically available:
All of this out of the box information is great, but you can decorate it further by using the OpenTelemetry API. Using the example code in this repo as a guide, try to do the following:
Thanks for checking out this tutorial! Any questions, please start a discussion. Bugs or other problems? Please file an issue. Hope it was helpful. :)
| Back | FazBrowse Home | New Git URL |