zipkin-tracer 0.12.0 → 0.12.1

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDU1NDhkYTRmYTdjMGI5ZDg0M2ZhZDRmZTY3ZWI3MjQ0ZjAyMGQwMQ==
4
+ MzEzZmRjNmE5ZjhhMGRiY2EyOWFiNzIxZjczZjE0MDlkOWJkY2MyNQ==
5
5
  data.tar.gz: !binary |-
6
- OTcwOTZmNWYyYmIxNGIxMzY5NWVlYjM4ODVlMzQ2MGE0MTk1NjJiNg==
6
+ ZDg5N2IyOGViYTVhODc3OWNlM2FjNGZmOTg3YjI5NjE0OGVlN2IwOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTE4ZThiOTZjN2Y2MWUxNDBhMDRlMGZjYjI1NGUwZGIyNWQ0YThhNmFiN2I0
10
- NzJjNzJiYmE0ZWJkNmFhZTI1YzYxNGFiYjk1NjM4NGZjNTZhMjQzZjMxODgx
11
- ZTM3NmM1M2Y4OGFkNDc4ZTBkNDM3MTc4MjMyMWM5MWIyMjU0OTc=
9
+ YjBlMDNiNzE3Y2EzYWZmNjU1MGY5Yzg2N2RjZTA1YmFiZWIzYjEzZDU0MDdh
10
+ MjExNGJkZjBiZjU3MjlhYzQwMTc4YWY1YjZhMWI5ZTc0Y2ViYjQxMzgwYWJk
11
+ NjIzN2Y0YzQ5ZDQ4MWY3ZjA4OTFlM2M5MzQxYzk5YzdiMzZmNjg=
12
12
  data.tar.gz: !binary |-
13
- YTU1YjJkZDU5NTU3MzY3OWFmNzE4Yjk4OTM0MGM5YTE3NjUyMzY1MzJmOGE0
14
- MDNhYWNmNGI3NjEyMGQ3OGE4NDEyODRjZWQzNjUwYmEyMGIwMWFhNzU4ZDBi
15
- MGRhMjM0YTRlNjE0ZTdhNjA0NTMzOTA4ZjYyYTNhNjg2Y2MxMWM=
13
+ OTFlZDAwZGZjNDE2ZGM1NmZmOGJlM2ZkNTQ1N2M2YTc5MzIwZjM4MDUxYjgz
14
+ YWY1MGZiYjY1OWVjNjcyNWJjNzE2ODM5MjhkNTYwMjhmYjgwNjcxNDI2YjYw
15
+ ZmQ4MTQ3MTIxYTMxNTA3Mzg2MzQ5ZTczYWUwMjBmMWRiNWUxZjE=
@@ -22,7 +22,7 @@ module ZipkinTracer
22
22
 
23
23
  def call(env)
24
24
  trace_id = Trace.id.next_id
25
- with_trace_id(trace_id) do
25
+ Trace.with_trace_id(trace_id) do
26
26
  B3_HEADERS.each do |method, header|
27
27
  env[:request_headers][header] = trace_id.send(method).to_s
28
28
  end
@@ -62,12 +62,5 @@ module ZipkinTracer
62
62
  response
63
63
  end
64
64
 
65
- def with_trace_id(trace_id, &block)
66
- Trace.push(trace_id)
67
- yield
68
- ensure
69
- Trace.pop
70
- end
71
-
72
65
  end
73
66
  end
@@ -34,7 +34,7 @@ module ZipkinTracer
34
34
  def call(env)
35
35
  zipkin_env = ZipkinEnv.new(env, @config)
36
36
  trace_id = zipkin_env.trace_id
37
- with_trace_id(trace_id) do
37
+ Trace.with_trace_id(trace_id) do
38
38
  if !trace_id.sampled? || !Application.routable_request?(env['PATH_INFO'])
39
39
  @app.call(env)
40
40
  else
@@ -47,13 +47,6 @@ module ZipkinTracer
47
47
 
48
48
  private
49
49
 
50
- def with_trace_id(trace_id, &block)
51
- Trace.push(trace_id)
52
- yield
53
- ensure
54
- Trace.pop
55
- end
56
-
57
50
  def annotate_plugin(env, status, response_headers, response_body)
58
51
  @config.annotate_plugin.call(env, status, response_headers, response_body) if @config.annotate_plugin
59
52
  end
@@ -8,6 +8,13 @@ module Trace
8
8
  @tracer
9
9
  end
10
10
 
11
+ def self.with_trace_id(trace_id, &block)
12
+ self.push(trace_id)
13
+ yield
14
+ ensure
15
+ self.pop
16
+ end
17
+
11
18
  # A span may contain many annotations
12
19
  # This class is defined in finagle-thrift. We are adding extra methods here
13
20
  class Span
@@ -12,9 +12,11 @@ module ZipkinTracer
12
12
 
13
13
  def initialize(name, &block)
14
14
  @trace_id = Trace.id.next_id
15
- Trace.tracer.with_new_span(@trace_id, name) do |span|
16
- @span = span
17
- block.call(self)
15
+ Trace.with_trace_id(@trace_id) do
16
+ Trace.tracer.with_new_span(@trace_id, name) do |span|
17
+ @span = span
18
+ block.call(self)
19
+ end
18
20
  end
19
21
  end
20
22
 
@@ -12,5 +12,5 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  module ZipkinTracer
15
- VERSION = "0.12.0"
15
+ VERSION = "0.12.1"
16
16
  end
@@ -26,7 +26,7 @@ module Trace
26
26
  end
27
27
 
28
28
  def may_flush(span)
29
- size = spans.values.map(&:size).inject(:+) || 0
29
+ size = spans.values.map(&:size).map(&:to_i).inject(:+) || 0
30
30
  if size >= @traces_buffer || span.annotations.any?{ |ann| ann.value == Annotation::SERVER_SEND }
31
31
  flush!
32
32
  reset
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipkin-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franklin Hu
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2016-02-02 00:00:00.000000000 Z
16
+ date: 2016-02-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: faraday