faraday-tracer 0.5.0 → 0.6.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: ebb9960d735ab728eeb7ea97317ac3378a4b7111
4
- data.tar.gz: b9af0f69baaddb24470e057d34e78fb37d9eaa8d
3
+ metadata.gz: 432de20c11ea8f776a334a35b499a0167f1dc9c5
4
+ data.tar.gz: a1aefc8b0851bb24e3712ffba9d121c9231803d1
5
5
  SHA512:
6
- metadata.gz: 30bd6106865461b9fff352d085ed182fc217b1cb9194d9f717bc3cee8cb7f5aa8165cd163cda261d222b6b791e33d7ef5ca2b44540d36affdaab1d8db8f471b3
7
- data.tar.gz: 27192e04ec6ce63b7cea72c362e9321e74b91b089fc813d86aa7df984b4caf5fabf56ea4fc380cd541d99010f3e6b3c75a44ae55af37c3b9438415d932552794
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
 
@@ -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.5.0'
7
+ spec.version = '0.6.0'
8
8
  spec.authors = ['SaleMove TechMovers']
9
9
  spec.email = ['techmovers@salemove.com']
10
10
 
@@ -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(app, span: nil, service_name: nil, tracer: OpenTracing.global_tracer, errors: [StandardError])
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[:method].to_s.upcase,
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SaleMove TechMovers