zipkin-tracer 0.16.0 → 0.17.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
- ZjYzMGY3YjgxYmZjMjdkMjU1Y2MyZDcxOTI2MDBjZjM3Y2ZlMmI5ZA==
4
+ NGI3MWNlMzU2NDUzNzdiYjg3MmEyNzFiZjIyZGQ0NmE2NzQzNjg3ZQ==
5
5
  data.tar.gz: !binary |-
6
- NGRmYmRjZTA1MGJlMmE5ZWU3MzE5ZmI3MTFkN2EwNDAxNDVmZWFhNQ==
6
+ MjZlZDcxMGYyNTY4NDdhMWQxZWNlMDg4YzY2YTI5Y2I5M2UyNTNkOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTgxNDgxNjg5NGYwMWM1YWIzNzQ0MDViY2IzMmE5ODRlNjgyMDkyNmJmZWIw
10
- NjBhNDg5NDA4Njg1NTI1YjU2ODcyZTM4YmZhNTBjMTUwOWZhNDE2NjcyN2Jm
11
- YzEwMmJkNWQ2NTg3NTdkM2YzZjFhZmE1M2JmY2ZiZjY5OTczNmU=
9
+ N2NiZjRiYTA3MmUwMTViZGFkNDZiYWFkNzRkY2U1ZmNlYjhjOTE4ZTkwYjY1
10
+ YzAzYjVlOGM5OGQyMWY0ZDAwYzFiN2QzNDA5MWFkMDdjMWU5Y2VlZTdjMGY3
11
+ YmVkNjVmYmNiNDkzZmYzM2ViYjdiNjUyOTUzMzM2MTA2MDVhYTI=
12
12
  data.tar.gz: !binary |-
13
- MDRkODlhMGEzYWE0M2M1YmI1OTNkMTg4MDJjOWI5ZWRjNDIwNTY3ZWUwNzc4
14
- OGE1YmQ3YTBhNTRlMzE4ZmE4YmI2NDNhMzIwNGQ1MzVkMDA1YTdiNDEwODYw
15
- MzllMTFhYTI3ZGNiYjdmNDhkZmQzMzZlY2VhM2FhNjY1YzUyYmQ=
13
+ ZWRkY2VhZjNmZTM5MjY1YjJiN2FhMjM3N2I1MTQ0MDhlNzhjZmEzNDYxMzhm
14
+ ODYzN2JlN2YyMWRlNDVmMTgwMTlmYmU4NTQwYTJlNTRkNzBhNDUyODRlZDQ4
15
+ NzBlYjJiM2MxN2E3MjM1Yzg5ZTEzMTY2ZmYzNjg2YWY3MjlkM2Q=
@@ -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.16.0'.freeze
15
+ VERSION = '0.17.0'.freeze
16
16
  end
@@ -1,5 +1,10 @@
1
- require 'hermann/producer'
2
- require 'hermann/discovery/zookeeper'
1
+ # IF hermann isn't present, we might be providing another kafka producer
2
+ begin
3
+ require 'hermann/producer'
4
+ require 'hermann/discovery/zookeeper'
5
+ rescue LoadError => e
6
+ end
7
+
3
8
  require 'zipkin-tracer/zipkin_tracer_base'
4
9
  require 'zipkin-tracer/hostname_resolver'
5
10
 
@@ -11,11 +16,16 @@ module Trace
11
16
 
12
17
  def initialize(options = {})
13
18
  @topic = options[:topic] || DEFAULT_KAFKA_TOPIC
14
- broker_ids = Hermann::Discovery::Zookeeper.new(options[:zookeepers]).get_brokers
15
- @producer = Hermann::Producer.new(nil, broker_ids)
19
+
20
+ if options[:producer] && options[:producer].respond_to?(:push)
21
+ @producer = options[:producer]
22
+ elsif options[:zookeepers]
23
+ initialize_hermann_producer(options[:zookeepers])
24
+ else
25
+ raise ArgumentError, "No (kafka) :producer option (accepting #push) and no :zookeeper option provided."
26
+ end
16
27
  super(options)
17
28
  end
18
-
19
29
  def flush!
20
30
  resolved_spans = ::ZipkinTracer::HostnameResolver.new.spans_with_ips(spans)
21
31
  resolved_spans.each do |span|
@@ -23,10 +33,23 @@ module Trace
23
33
  trans = Thrift::MemoryBufferTransport.new(buf)
24
34
  oprot = Thrift::BinaryProtocol.new(trans)
25
35
  span.to_thrift.write(oprot)
26
- @producer.push(buf, topic: @topic).value!
36
+
37
+ retval = @producer.push(buf, topic: @topic)
38
+
39
+ # If @producer#push returns a promise/promise-like object, block until it
40
+ # resolves
41
+ retval.value! if retval.respond_to?(:value!)
42
+
43
+ retval
27
44
  end
28
45
  rescue Exception
29
46
  # Ignore socket errors, etc
30
47
  end
48
+
49
+ private
50
+ def initialize_hermann_producer(zookeepers)
51
+ broker_ids = Hermann::Discovery::Zookeeper.new(zookeepers).get_brokers
52
+ @producer = Hermann::Producer.new(nil, broker_ids)
53
+ end
31
54
  end
32
55
  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.16.0
4
+ version: 0.17.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: 2016-02-29 00:00:00.000000000 Z
16
+ date: 2016-04-13 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: faraday