openzipkin / zipkin-ruby-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic example showing distributed tracing across ruby apps

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 zipkin screen shot

This example was ported from similar examples, such as Brave.

Implementation Overview

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.

Setup

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

Starting the Services

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

Running the example

Once the services are started, open http://localhost:8081/

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

About

License:Apache License 2.0


Languages

Language:Ruby 100.0%