faraday-tracer 0.1.3 → 0.2.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: 5653805c639af977f9e4900d34fd90a1deee489d
4
- data.tar.gz: 6ff3e871000bdc5dfdf2ac89f79cb4672c09ca04
3
+ metadata.gz: c62dc7fa9782e900ed0a8670f17a09d9fe6c72ff
4
+ data.tar.gz: b4deecc8fd5c8d17db0e553852a84457885f5ad3
5
5
  SHA512:
6
- metadata.gz: 96d66a7f438c6c9b3a70ddd3ff59c3702f7cbae5324d1efaac2e270643b5ca1aee2afde3b1cbaa229467a130da55beec354c085fa735148975ff435c6c4439a8
7
- data.tar.gz: 28f0f92cdb6e8d13df6d7ee2257ac5bef8c24027612d647edc79cf25690c262d49a18a1f87a96ddb98a5081e706747777acd2467345ae050be861bcce6139eb1
6
+ metadata.gz: 8eb062c0f11493e4ea7fcf8da004826ede0d552ee6f4ff1a859f8cc9a654d558bf3072520ee2ab340306b0c504d277782a9516f7bb3d5913d8c365f0b0002e7e
7
+ data.tar.gz: e8a902373253201fd282e9f06869f6dc567bf35fe5db8b440e0955ef29d6c07ae6196f8e8103aa1b2906c82ae2d1c9d30a57798df8460e2212616b2da8c536d7
data/README.md CHANGED
@@ -40,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
40
40
 
41
41
  ## Contributing
42
42
 
43
- Bug reports and pull requests are welcome on GitHub at https://github.com/salemove/faraday-tracer.
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/opentracing-contrib/ruby-faraday-tracer.
44
44
 
45
45
 
46
46
  ## License
@@ -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.1.3'
7
+ spec.version = '0.2.0'
8
8
  spec.authors = ['SaleMove TechMovers']
9
9
  spec.email = ['techmovers@salemove.com']
10
10
 
@@ -3,15 +3,26 @@ require 'opentracing'
3
3
 
4
4
  module Faraday
5
5
  class Tracer < Faraday::Middleware
6
- def initialize(app, span: nil, tracer: OpenTracing.global_tracer)
6
+ # Create a new Faraday Tracer middleware.
7
+ #
8
+ # @param app The faraday application/middlewares stack.
9
+ # @param span [Span, SpanContext, Proc, nil] SpanContext that acts as a parent to
10
+ # the newly-started by the middleware Span. If a Proc is provided, its
11
+ # evaluated during the call method invocation.
12
+ # @param tracer [OpenTracing::Tracer] A tracer to be used when start_span, and inject
13
+ # is called.
14
+ # @param errors [Array<Class>] An array of error classes to be captured by the tracer
15
+ # as errors. Errors are **not** muted by the middleware.
16
+ def initialize(app, span: nil, tracer: OpenTracing.global_tracer, errors: [StandardError])
7
17
  super(app)
8
18
  @tracer = tracer
9
19
  @parent_span = span
20
+ @errors = errors
10
21
  end
11
22
 
12
23
  def call(env)
13
24
  span = @tracer.start_span(env[:method].to_s.upcase,
14
- child_of: @parent_span,
25
+ child_of: @parent_span.respond_to?(:call) ? @parent_span.call : @parent_span,
15
26
  tags: {
16
27
  'component' => 'faraday',
17
28
  'span.kind' => 'client',
@@ -22,8 +33,13 @@ module Faraday
22
33
  @tracer.inject(span.context, OpenTracing::FORMAT_RACK, env[:request_headers])
23
34
  @app.call(env).on_complete do |response|
24
35
  span.set_tag('http.status_code', response.status)
25
- span.finish
26
36
  end
37
+ rescue *@errors => e
38
+ span.set_tag('error', true)
39
+ span.log(event: 'error', :'error.object' => e)
40
+ raise
41
+ ensure
42
+ span.finish
27
43
  end
28
44
  end
29
45
  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.1.3
4
+ version: 0.2.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: 2017-07-27 00:00:00.000000000 Z
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentracing