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 +4 -4
- data/README.md +29 -0
- data/faraday-tracer.gemspec +1 -1
- data/lib/faraday/tracer.rb +12 -1
- 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: 64f607d713975def48233f8a8308a896dbce4fd3
|
4
|
+
data.tar.gz: 0454f69a116f4fdfbe2f74126a5db084c05898f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/faraday-tracer.gemspec
CHANGED
data/lib/faraday/tracer.rb
CHANGED
@@ -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:
|
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.
|
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-
|
11
|
+
date: 2018-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|