This is an example app where two sinatra (ruby) services collaborate on an http request. Notably, timing of these requests are recorded into Zipkin, a distributed tracing system. This allows you to see the how long the whole operation took, as well how much time was spent in each service.
Here's an example of what it looks like
This example was ported from similar examples, such as Brave.
Web requests are served by Sinatra routes, and tracing is automatically performed for you by zipkin-ruby.
This example has two services: frontend and backend. They both report trace data to zipkin. To setup the demo, you need to start frontend.rb, backend.rb and Zipkin.
Before you start anything, you'll need to download the libraries used in this demo:
# get the latest version of zipkin-ruby
$ bundle update
# install the example
$ bundle install
You'll also want to download zipkin.
$ curl -sSL https://zipkin.io/quickstart.sh | bash -s
In a separate tab or window, start each of frontend.rb and backend.rb:
$ ruby frontend.rb
$ ruby backend.rb
Next, run Zipkin, which stores and queries traces reported by and above services.
$ java -jar zipkin.jar
Once the services are started, open http://localhost:8081/
- This will call the backend (http://localhost:9000/api) and show the result, which defaults to a formatted date.
Now, you can view traces that went through the frontend via http://localhost:9411/?serviceName=frontend
- This is a locally run zipkin service which keeps traces in memory