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 +4 -4
- data/README.md +1 -1
- data/faraday-tracer.gemspec +1 -1
- data/lib/faraday/tracer.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c62dc7fa9782e900ed0a8670f17a09d9fe6c72ff
|
4
|
+
data.tar.gz: b4deecc8fd5c8d17db0e553852a84457885f5ad3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
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
|
data/faraday-tracer.gemspec
CHANGED
data/lib/faraday/tracer.rb
CHANGED
@@ -3,15 +3,26 @@ require 'opentracing'
|
|
3
3
|
|
4
4
|
module Faraday
|
5
5
|
class Tracer < Faraday::Middleware
|
6
|
-
|
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.
|
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-
|
11
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|