lookout-zipkin-tracer 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODdmODRhZmY4N2E4OWZmNzc5MzliOGUzMjI2NmJlMDRjY2IwMDhhNw==
4
+ ZDZiZjZlOWE5OWQ0ZmE3YzY0NjUzOWY3ZGE2ZDIxNzQ2MzFlNGY1MA==
5
5
  data.tar.gz: !binary |-
6
- MTAxMDgzY2QzYTZmN2QxOGRmZjNjYzhiYTQ1NzZkYWI5NmZiZDY0NQ==
6
+ MzJjNWU5YjE0NjM1NDY1YWNiMGNiZTcwYjU1MmZkMmYwMzU2MDA4Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzJhNTdiNDQ2OGE1MDhjZWMwMzQ4M2JmMDc0OTg3NTY5ZTg1YTIwYzJiZjdh
10
- MDRkYWRlYWY0NzZlYTkyYjQ4M2I2N2ZkOTUzZTRkODcxNWFhNzJlYjMzOWM1
11
- MjQ4NmY1MDg5NjA1ZmFkMzE0Njc0ZWUxMTI2YjA0OWYwZjY4Mzg=
9
+ NGEyYWUxZjFlYzVmN2FjZGYzNzU0MTY3YTdkNDEwZjY2MDEwNzI4ZGRjNThl
10
+ MWY4YTYxNzU5ZDk2YjkzYjIzMzg0ZGNhMjZhOTY4YzFlMThhMzNiNzZmZjJi
11
+ YWE4MTVhZmQ4MjZlMTY4MzZjNjk3MDVlODdjZDYyNjQyNWI5N2M=
12
12
  data.tar.gz: !binary |-
13
- NDAzNGU5ZGMwYTgyYzM2ZmIzZjIwODJkMTI3NTc5NDg1MjcxZGU4MTgwMjVh
14
- MzgzZjNhYTlkZDc3MTkyYTQwYTIyYWRkNThjNmIxNWZmM2Y5NGMzMjNhYmY5
15
- ZDc2YmUxYTgyZTNlYzU3NTYxYzU1ZTlkNmY5MjRmNjA1MGVhYzA=
13
+ YjM2N2ZiNjhhMjRlN2QzZTFlZTI3MGYxZTc4MDE4MjEzYWM5Yzc5ZmJmMjAz
14
+ NjBlN2ZlZWJjMGQwZmFlOWMwYWEzZTI0OTNhMTViNGZiZjRlNjI2ZmUwMTdi
15
+ NjNmNjI3MmEyYjE4ZDc2ZDJjMjU2NWJkMzg2Y2FjYWZiYWZiMDY=
data/lib/zipkin-tracer.rb CHANGED
@@ -14,9 +14,12 @@
14
14
  require 'finagle-thrift'
15
15
  require 'finagle-thrift/trace'
16
16
  require 'scribe'
17
-
18
17
  require 'zipkin-tracer/careless_scribe'
19
18
 
19
+ if RUBY_PLATFORM == 'java'
20
+ require 'zipkin-tracer/zipkin_kafka_tracer'
21
+ end
22
+
20
23
  module ZipkinTracer extend self
21
24
 
22
25
  class RackHandler
@@ -31,32 +34,22 @@ module ZipkinTracer extend self
31
34
  @service_name = config[:service_name]
32
35
  @service_port = config[:service_port]
33
36
 
34
- scribe =
35
- if config[:scribe_server] then
36
- Scribe.new(config[:scribe_server])
37
- else
38
- Scribe.new()
39
- end
40
-
41
- scribe_max_buffer =
42
- if config[:scribe_max_buffer] then
43
- config[:scribe_max_buffer]
44
- else
45
- 10
46
- end
47
-
48
- @sample_rate =
49
- if config[:sample_rate] then
50
- config[:sample_rate]
51
- else
52
- 0.1
53
- end
37
+ if config[:scribe_server]
38
+ scribe = config[:scribe_server] ? Scribe.new(config[:scribe_server]) : Scribe.new()
39
+ careless_scribe = CarelessScribe.new(scribe)
40
+ scribe_max_buffer = config[:scribe_max_buffer] ? config[:scribe_max_buffer] : 10
41
+ ::Trace.tracer = ::Trace::ZipkinTracer.new(careless_scribe, scribe_max_buffer)
42
+ elsif config[:zookeeper] && RUBY_PLATFORM == 'java'
43
+ kafkaTracer = ::Trace::ZipkinKafkaTracer.new
44
+ kafkaTracer.connect(config[:zookeeper])
45
+ ::Trace.tracer = kafkaTracer
46
+ end
47
+
48
+ @sample_rate = config[:sample_rate] ? config[:sample_rate] : 0.1
54
49
 
55
50
  @annotate_plugin = config[:annotate_plugin] # call for trace annotation
56
51
  @filter_plugin = config[:filter_plugin] # skip tracing if returns false
57
52
  @whitelist_plugin = config[:whitelist_plugin] # force sampling if returns true
58
-
59
- ::Trace.tracer = ::Trace::ZipkinTracer.new(CarelessScribe.new(scribe), scribe_max_buffer)
60
53
  end
61
54
 
62
55
  def call(env)
@@ -12,6 +12,6 @@
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.3.0"
15
+ VERSION = "0.5.0"
16
16
  end
17
17
 
@@ -0,0 +1,65 @@
1
+ require 'finagle-thrift'
2
+ require 'finagle-thrift/tracer'
3
+ require 'hermann/producer'
4
+ require 'hermann/discovery/zookeeper'
5
+
6
+ module Trace
7
+ class ZipkinKafkaTracer < Tracer
8
+ TRACER_CATEGORY = "zipkin".freeze
9
+ DEFAULT_KAFKA_TOPIC = "zipkin_kafka".freeze
10
+
11
+ def initialize(opts={})
12
+ @logger = opts[:logger]
13
+ @topic = opts[:topic] || DEFAULT_KAFKA_TOPIC
14
+ reset
15
+ end
16
+
17
+ # need to connect after initialization
18
+ def connect(zookeepers)
19
+ broker_ids = Hermann::Discovery::Zookeeper.new(zookeepers).get_brokers
20
+ @producer = Hermann::Producer.new(nil, broker_ids)
21
+ end
22
+
23
+ def record(id, annotation)
24
+ return unless id.sampled?
25
+ span = get_span_for_id(id)
26
+
27
+ case annotation
28
+ when BinaryAnnotation
29
+ span.binary_annotations << annotation
30
+ when Annotation
31
+ span.annotations << annotation
32
+ end
33
+
34
+ flush!
35
+ end
36
+
37
+ def set_rpc_name(id, name)
38
+ return unless id.sampled?
39
+ span = get_span_for_id(id)
40
+ span.name = name.to_s
41
+ end
42
+
43
+ private
44
+ def reset
45
+ @spans = {}
46
+ end
47
+
48
+ def get_span_for_id(id)
49
+ key = id.span_id.to_s
50
+ @spans[key] ||= begin
51
+ Span.new("", id)
52
+ end
53
+ end
54
+
55
+ def flush!
56
+ messages = @spans.values.map do |span|
57
+ buf = ''
58
+ trans = Thrift::MemoryBufferTransport.new(buf)
59
+ oprot = Thrift::BinaryProtocol.new(trans)
60
+ span.to_thrift.write(oprot)
61
+ @producer.push(buf, :topic => @topic).value!
62
+ end
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookout-zipkin-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Salomon, Franklin Hu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: finagle-thrift
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: thin
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: Adds tracing instrumentation for ruby applications
98
84
  email:
99
85
  - ariel@lookout.com, franklin@twitter.com
@@ -101,9 +87,10 @@ executables: []
101
87
  extensions: []
102
88
  extra_rdoc_files: []
103
89
  files:
104
- - lib/zipkin-tracer.rb
105
90
  - lib/zipkin-tracer/careless_scribe.rb
106
91
  - lib/zipkin-tracer/version.rb
92
+ - lib/zipkin-tracer/zipkin_kafka_tracer.rb
93
+ - lib/zipkin-tracer.rb
107
94
  homepage: https://github.com/lookout/zipkin
108
95
  licenses: []
109
96
  metadata: {}
@@ -123,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
110
  version: 1.3.5
124
111
  requirements: []
125
112
  rubyforge_project:
126
- rubygems_version: 2.2.2
113
+ rubygems_version: 2.1.11
127
114
  signing_key:
128
115
  specification_version: 4
129
116
  summary: Ruby tracing via Zipkin