faraday-tracer 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/faraday-tracer.gemspec +1 -1
- data/lib/faraday/tracer.rb +16 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432de20c11ea8f776a334a35b499a0167f1dc9c5
|
4
|
+
data.tar.gz: a1aefc8b0851bb24e3712ffba9d121c9231803d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf1faceda09cf8bcfc3f5d6345b540ca06f88bb8dd64fec1d1ec52b722eed5d14a8b4c7d29cee1d34cee0f393c8c78300072ec27042bfa45a256ca3c61b47a66
|
7
|
+
data.tar.gz: f65ec3f75d87f20fd1a7f6e8b4f417997e51beb8f528f26e1219bd8a5d671a9563ba0c477b1fa2a573519c427c3052cec3fa7cc5aa644aad10e1cc42f17ac37e
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Faraday::Tracer
|
2
2
|
|
3
|
-
OpenTracing compatible Faraday middleware
|
3
|
+
OpenTracing compatible Faraday middleware:
|
4
|
+
|
5
|
+
* It wraps all outgoing requests in spans
|
6
|
+
* It adds the trace context to outgoing requests
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -61,6 +64,11 @@ conn = Faraday.new(url: 'http://localhost:3000/') do |faraday|
|
|
61
64
|
end
|
62
65
|
```
|
63
66
|
|
67
|
+
### Span name
|
68
|
+
|
69
|
+
By default, all spans are given a default name. You may also override this by
|
70
|
+
passing a `:span_name` in the middleware options hash and/or the request
|
71
|
+
options.
|
64
72
|
|
65
73
|
### Service name
|
66
74
|
|
data/faraday-tracer.gemspec
CHANGED
data/lib/faraday/tracer.rb
CHANGED
@@ -9,22 +9,31 @@ module Faraday
|
|
9
9
|
# @param span [Span, SpanContext, Proc, nil] SpanContext that acts as a parent to
|
10
10
|
# the newly-started by the middleware Span. If a Proc is provided, its
|
11
11
|
# evaluated during the call method invocation.
|
12
|
+
# @param span_name [String, nil] The name of the span to create.
|
12
13
|
# @param service_name [String, nil] Remote service name (for some
|
13
14
|
# unspecified definition of "service")
|
14
15
|
# @param tracer [OpenTracing::Tracer] A tracer to be used when start_span, and inject
|
15
16
|
# is called.
|
16
17
|
# @param errors [Array<Class>] An array of error classes to be captured by the tracer
|
17
18
|
# as errors. Errors are **not** muted by the middleware.
|
18
|
-
def initialize(
|
19
|
+
def initialize(
|
20
|
+
app,
|
21
|
+
span: nil,
|
22
|
+
span_name: nil,
|
23
|
+
service_name: nil,
|
24
|
+
tracer: OpenTracing.global_tracer,
|
25
|
+
errors: [StandardError]
|
26
|
+
)
|
19
27
|
super(app)
|
20
28
|
@tracer = tracer
|
21
29
|
@parent_span = span
|
30
|
+
@span_name = span_name
|
22
31
|
@service_name = service_name
|
23
32
|
@errors = errors
|
24
33
|
end
|
25
34
|
|
26
35
|
def call(env)
|
27
|
-
span = @tracer.start_span(env
|
36
|
+
span = @tracer.start_span(span_name(env),
|
28
37
|
child_of: parent_span(env),
|
29
38
|
tags: prepare_tags(env)
|
30
39
|
)
|
@@ -42,6 +51,11 @@ module Faraday
|
|
42
51
|
|
43
52
|
private
|
44
53
|
|
54
|
+
def span_name(env)
|
55
|
+
context = env.request.context
|
56
|
+
context.is_a?(Hash) && context[:span_name] || @span_name || env[:method].to_s.upcase
|
57
|
+
end
|
58
|
+
|
45
59
|
def parent_span(env)
|
46
60
|
context = env.request.context
|
47
61
|
span = context.is_a?(Hash) && context[:span] || @parent_span
|