faraday-tracer 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 993a3acba723ece134d346cb9ceed77d05d6a7bb
4
- data.tar.gz: d2e69959bc6c063c567216bf246372e5e92149b2
3
+ metadata.gz: 64f607d713975def48233f8a8308a896dbce4fd3
4
+ data.tar.gz: 0454f69a116f4fdfbe2f74126a5db084c05898f6
5
5
  SHA512:
6
- metadata.gz: 30e6f601be1807e8884f9a32c5bd16da5816de1b6adeccb5fab83b30bb2d475d7c28f83a667efb101198905969558ae572e85e91ec2963cec0f7027ae3e08c21
7
- data.tar.gz: d31c003982a524fa62775212c50f7d5aa80514872aaf05b07478dc9734e1dea4bd95f473db4478acd88f30f0d947879937524d074a4297eb9ce0b889abbf4aaf
6
+ metadata.gz: fcec16b4cc9f6165c7570da33cc12f5fe2cb545b5250c95a3d12ffd1a8e8cd6c0d36763fb9813cecb62e9b94999b00ae5be4cd3a9cfbafd9abcf4f89df6af4d7
7
+ data.tar.gz: 796d59ae3ab0758dfca00a98cfec28cee08a90070bc07047edbc4889934832afc8608d88fe0116da06f49b89850c8d0287d8150dcebe28364f416fa49eedd774
data/README.md CHANGED
@@ -12,6 +12,35 @@ gem 'faraday-tracer'
12
12
 
13
13
  ## Usage
14
14
 
15
+ ### Using request context
16
+
17
+ ```ruby
18
+ require 'opentracing'
19
+ OpenTracing.global_tracer = TracerImplementation.new
20
+
21
+ require 'faraday'
22
+ require 'faraday/tracer'
23
+
24
+ conn = Faraday.new(url: 'http://localhost:3000/') do |faraday|
25
+ # Add tracing support
26
+ faraday.use Faraday::Tracer
27
+
28
+ # default Faraday stack
29
+ faraday.request :url_encoded
30
+ faraday.adapter Faraday.default_adapter
31
+ end
32
+
33
+ span = request.env['rack.span'] # when using rack-tracer gem
34
+
35
+ conn.post('/test') do |request|
36
+ # Leave undefined or set span to nil if there's no existing span
37
+ request.options.context = {span: span}
38
+ end
39
+ ```
40
+
41
+
42
+ ### Defining span in the connection builder
43
+
15
44
  ```ruby
16
45
  require 'opentracing'
17
46
  OpenTracing.global_tracer = TracerImplementation.new
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'faraday-tracer'
7
- spec.version = '0.3.0'
7
+ spec.version = '0.4.0'
8
8
  spec.authors = ['SaleMove TechMovers']
9
9
  spec.email = ['techmovers@salemove.com']
10
10
 
@@ -22,7 +22,7 @@ module Faraday
22
22
 
23
23
  def call(env)
24
24
  span = @tracer.start_span(env[:method].to_s.upcase,
25
- child_of: @parent_span.respond_to?(:call) ? @parent_span.call : @parent_span,
25
+ child_of: parent_span(env),
26
26
  tags: {
27
27
  'component' => 'faraday',
28
28
  'span.kind' => 'client',
@@ -41,5 +41,16 @@ module Faraday
41
41
  ensure
42
42
  span.finish
43
43
  end
44
+
45
+ private
46
+
47
+ def parent_span(env)
48
+ context = env.request.context
49
+ span = context.is_a?(Hash) && context[:span] || @parent_span
50
+
51
+ if span
52
+ span.respond_to?(:call) ? span.call : span
53
+ end
54
+ end
44
55
  end
45
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SaleMove TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentracing