zipkin-tracer 0.25.0 → 0.26.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f3c839257069386e2ee919af9359519db3d601d
|
4
|
+
data.tar.gz: c3a5348a47ffcf3823ef079e7bf59f83bd73cf7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a1bd29f82318ff6391b9575701ac7a65831147b87dc7c434e7930ad77fb569e87f8485480ff1f6400cdd55ac1320a2a055179001a3d9aa0a5ac27e5a7b743f6
|
7
|
+
data.tar.gz: fd4800c057745f5ae23bae36dcb34655fc612cb7aa34d7cbd5cf77718c74c09f2debd1745f3c2e158ddd09ec5f219eba8f37ae5f2464af7ddf25dd06353fb1ae
|
data/lib/zipkin-tracer.rb
CHANGED
@@ -2,6 +2,7 @@ require 'finagle-thrift'
|
|
2
2
|
require 'base64' #Bug in finagle. They should be requiring this: finagle-thrift-1.4.1/lib/finagle-thrift/tracer.rb:115
|
3
3
|
require 'zipkin-tracer/trace'
|
4
4
|
require 'zipkin-tracer/rack/zipkin-tracer'
|
5
|
+
require 'zipkin-tracer/sidekiq/middleware'
|
5
6
|
require 'zipkin-tracer/trace_client'
|
6
7
|
require 'zipkin-tracer/trace_container'
|
7
8
|
require 'zipkin-tracer/trace_generator'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module ZipkinTracer
|
2
|
+
module Sidekiq
|
3
|
+
class Middleware
|
4
|
+
attr_reader :config, :tracer, :traceable_workers
|
5
|
+
|
6
|
+
def initialize(config)
|
7
|
+
@config = Config.new(nil, config).freeze
|
8
|
+
@tracer = TracerFactory.new.tracer(@config)
|
9
|
+
@traceable_workers = config.fetch(:traceable_workers, [])
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(worker, job, queue, &block)
|
13
|
+
return block.call unless traceable_worker?(worker)
|
14
|
+
|
15
|
+
trace(worker, job, queue, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def traceable_worker?(worker)
|
21
|
+
traceable_workers.include?(:all) || traceable_workers.include?(worker_name(worker))
|
22
|
+
end
|
23
|
+
|
24
|
+
def trace(worker, job, queue, &block)
|
25
|
+
trace_id = TraceGenerator.new.next_trace_id
|
26
|
+
span_name = worker_name(worker)
|
27
|
+
|
28
|
+
result = TraceContainer.with_trace_id(trace_id) do
|
29
|
+
if trace_id.sampled?
|
30
|
+
tracer.with_new_span(trace_id, span_name) do
|
31
|
+
result = block.call
|
32
|
+
end
|
33
|
+
else
|
34
|
+
result = block.call
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
tracer.flush!
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
42
|
+
def worker_name(worker)
|
43
|
+
worker.class.to_s.to_sym
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/zipkin-tracer/trace.rb
CHANGED
@@ -23,7 +23,12 @@ module Trace
|
|
23
23
|
|
24
24
|
def end_span(span)
|
25
25
|
span.close
|
26
|
-
|
26
|
+
# If in a thread not handling incoming http requests, it will not have Annotation::SERVER_SEND, so the span
|
27
|
+
# will never be flushed and will cause memory leak.
|
28
|
+
# It will have CLIENT_SEND and CLIENT_RECV if the thread sends out http requests, so use CLIENT_RECV as the sign
|
29
|
+
# to flush the span.
|
30
|
+
# If no parent span, then current span needs to flush when it ends.
|
31
|
+
if !span.has_parent_span? || span.annotations.any? { |ann| ann.value == Annotation::SERVER_SEND }
|
27
32
|
flush!
|
28
33
|
reset
|
29
34
|
end
|
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.
|
4
|
+
version: 0.26.0
|
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: 2017-
|
16
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: faraday
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/zipkin-tracer/hostname_resolver.rb
|
176
176
|
- lib/zipkin-tracer/rack/zipkin-tracer.rb
|
177
177
|
- lib/zipkin-tracer/rack/zipkin_env.rb
|
178
|
+
- lib/zipkin-tracer/sidekiq/middleware.rb
|
178
179
|
- lib/zipkin-tracer/trace.rb
|
179
180
|
- lib/zipkin-tracer/trace_client.rb
|
180
181
|
- lib/zipkin-tracer/trace_container.rb
|