README.md in rails_distributed_tracing-1.0 vs README.md in rails_distributed_tracing-1.1
- old
+ new
@@ -1,10 +1,12 @@
# rails_distributed_tracing
Distributed tracing for rails microservices
+[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/ajitsing/rails_distributed_tracing/graphs/commit-activity)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://opensource.org/licenses/MIT)
[![Gem Version](https://badge.fury.io/rb/rails_distributed_tracing.svg)](https://badge.fury.io/rb/rails_distributed_tracing)
+[![HitCount](http://hits.dwyl.io/ajitsing/rails_distributed_tracing.svg)](http://hits.dwyl.io/ajitsing/rails_distributed_tracing)
![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/rails_distributed_tracing?type=total)
[![Build Status](https://travis-ci.org/ajitsing/rails_distributed_tracing.svg?branch=master)](https://travis-ci.org/ajitsing/rails_distributed_tracing)
[![Twitter Follow](https://img.shields.io/twitter/follow/Ajit5ingh.svg?style=social)](https://twitter.com/Ajit5ingh)
## Installation
@@ -19,11 +21,11 @@
```ruby
require 'rails_distributed_tracing'
class Application < Rails::Application
- config.log_tags = [DistributedTracing.request_id_tag]
+ config.log_tags = [DistributedTracing.log_tag]
end
```
## Passing request id tag to downstream services
To make the distributed tracing work every service has to the request id to all its downstream services.
@@ -39,23 +41,44 @@
## How to pass request id tag to downstream services
When a request id is generated `rails_distributed_tracing` holds that request id till the request returns the response. You can access that request_id anywhere in your application code with the help of below APIs.
```ruby
-DistributedTracing.current_request_id
+DistributedTracing.trace_id
+#=> '8ed7e37b-94e8-4875-afb4-6b4cf1783817'
```
-or you can directly get it as a request header
+## Sidekiq
+```ruby
+Sidekiq.configure_server do |config|
+ config.server_middleware do |chain|
+ chain.add DistributedTracing::SidekiqMiddleware::Server
+ end
+end
+Sidekiq.configure_client do |config|
+ config.client_middleware do |chain|
+ chain.add DistributedTracing::SidekiqMiddleware::Client
+ end
+end
+```
+
+## Faraday
```ruby
-DistributedTracing.request_id_header
-#=> {'Request-ID' => '8ed7e37b-94e8-4875-afb4-6b4cf1783817'}
+connection = Faraday.new("http://google.com/") do |conn|
+ conn.use DistributedTracing::FaradayMiddleware
+end
```
-The gem will automatically pick the `Request-ID` header from your request and use it as log tag.
+Make sure that faraday and sidekiq gems are loaded before `rails_distributed_tracing`. Otherwise rails_distributed_tracing will not load the faraday and sidekiq related classes.
-Note: Make sure that you always pass the current request id and not the stale one.
+To ensure that `sidekiq` and `faraday` are loaded before `rails_distributed_tracing`, add sidekiq and faraday gem before rails_distributed_tracing in Gemfile. So that when rails load the Gemfile, sidekiq and faraday loaded before rails_distributed_tracing gem.
+## Other
+Add below headers to the outgoing request headers.
+```ruby
+{DistributedTracing::TRACE_ID => DistributedTracing.trace_id}
+```
## Contributing
1. Fork it ( https://github.com/ajitsing/rails_distributed_tracing/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)