zipkin-tracer 0.37.0 → 0.38.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
  SHA256:
3
- metadata.gz: f71b9baf08a3f387fc409c40a8997d29da5a8dd48e9d4fa9609b02c2b4f2ea03
4
- data.tar.gz: a481c2dc583679f1bbbe4341ac896ad4594a7b7920562344b95ed23f6f266a1f
3
+ metadata.gz: 05de91c3ee2300d261bd19d481b4fe602e818f48ddce33294791543c04579f20
4
+ data.tar.gz: 883b5cc753bae954ab8fe432975a40899f617a0771b7352adfefffbc8cb1b0df
5
5
  SHA512:
6
- metadata.gz: 9bf32473266105e4b8dc1d19d3042937c451962aa8f58deac3f606d04205bc7f0fa8ad856169bd02d216193f22e085d8e7b48a317f99182ec0adf7dedab96509
7
- data.tar.gz: cc75da694fe165499b0f84c10d795d1e3e8f4c8fac6814531662c103e80330f668c298b7c76f16c8d94385f6550ff6afb489770cacfa6923d79dab826152c5b8
6
+ metadata.gz: e0c80c681f43960a95f03c28e34b506d7bf7161fd7b0c5d6ae185a8295ff31782ff99abcb6a43adf0a2053909200cd4f36808122c8e2bf3e20d13d946b4461f3
7
+ data.tar.gz: 743a4f9c0274c51beab9532cb6603d66499568ecc6c7fde0327fa72786be792653b45b333de970ec78285f2e367ee76d59489f27822d156d78e92d07f7eb20f5
data/.travis.yml CHANGED
@@ -20,8 +20,8 @@ deploy:
20
20
  notifications:
21
21
  webhooks:
22
22
  urls:
23
- - https://webhooks.gitter.im/e/637e968b45032d16ee26
23
+ - https://webhooks.gitter.im/e/ead3c37d57527214e9f2
24
+ - https://webhooks.gitter.im/e/e57478303f87ecd7bffc
24
25
  on_success: change
25
26
  on_failure: always
26
- on_start: false
27
27
  script: "bundle exec rspec"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.38.0
2
+ * Add RabbitMQ sender
3
+
1
4
  # 0.37.0
2
5
  * Add an `async` option to the HTTP and SQS senders.
3
6
  * Allow the `logger` option to be provided.
data/README.md CHANGED
@@ -30,6 +30,9 @@ use ZipkinTracer::RackHandler, config
30
30
  * `:zookeeper` - The address of the zookeeper server to use by the Kafka sender
31
31
  * `:sqs_queue_name` - The name of the Amazon SQS queue to use the SQS sender
32
32
  * `:sqs_region` - The AWS region for the Amazon SQS queue (optional)
33
+ * `:rabbit_mq_connection` - The bunny connection to be used by the RabbitMQ sender
34
+ * `:rabbit_mq_exchange` - The name of the exchange to be used by the RabbitMQ sender (optional)
35
+ * `:rabbit_mq_routing_key` - The name of the routing key to be used by the RabbitMQ sender (optional)
33
36
  * `:log_tracing` - Set to true to log all traces. Only used if traces are not sent to the API or Kafka.
34
37
 
35
38
  #### Plugins
@@ -142,6 +145,12 @@ The following [Amazon SQS permissions](https://docs.aws.amazon.com/AWSSimpleQueu
142
145
 
143
146
  Optionally, you can set `:sqs_region` to specify the AWS region to connect to.
144
147
 
148
+ ### RabbitMQ
149
+ Uses RabbitMQ as the transport
150
+
151
+ If `:rabbit_mq_connection` is set in the config, then the gem will use RabbitMQ. You will need to pass a [Bunny](https://github.com/ruby-amqp/bunny) connection.
152
+ You can optionally set the exchange name and routing key using `:rabbit_mq_exchange` and `:rabbit_mq_routing_key`
153
+
145
154
  ### Logger
146
155
 
147
156
  The simplest sender that does something. It will log all your spans.
@@ -7,7 +7,8 @@ module ZipkinTracer
7
7
  class Config
8
8
  attr_reader :service_name, :sample_rate, :sampled_as_boolean, :trace_id_128bit, :async, :logger,
9
9
  :json_api_host, :zookeeper, :kafka_producer, :kafka_topic, :sqs_queue_name, :sqs_region, :log_tracing,
10
- :annotate_plugin, :filter_plugin, :whitelist_plugin
10
+ :annotate_plugin, :filter_plugin, :whitelist_plugin, :rabbit_mq_connection, :rabbit_mq_exchange,
11
+ :rabbit_mq_routing_key
11
12
 
12
13
  def initialize(app, config_hash)
13
14
  config = config_hash || Application.config(app)
@@ -23,6 +24,10 @@ module ZipkinTracer
23
24
  # Amazon SQS queue information
24
25
  @sqs_queue_name = config[:sqs_queue_name]
25
26
  @sqs_region = config[:sqs_region]
27
+ # Rabbit MQ information
28
+ @rabbit_mq_connection = config[:rabbit_mq_connection]
29
+ @rabbit_mq_exchange = config[:rabbit_mq_exchange]
30
+ @rabbit_mq_routing_key = config[:rabbit_mq_routing_key]
26
31
  # Percentage of traces which by default this service traces (as float, 1.0 means 100%)
27
32
  @sample_rate = config[:sample_rate] || DEFAULTS[:sample_rate]
28
33
  # A block of code which can be called to do extra annotations of traces
@@ -66,6 +71,8 @@ module ZipkinTracer
66
71
  :kafka_producer
67
72
  elsif present?(@sqs_queue_name) && defined?(Aws::SQS)
68
73
  :sqs
74
+ elsif @rabbit_mq_connection
75
+ :rabbit_mq
69
76
  elsif !!@log_tracing
70
77
  :logger
71
78
  else
@@ -25,6 +25,16 @@ module ZipkinTracer
25
25
  region: config.sqs_region
26
26
  }
27
27
  Trace::ZipkinSqsSender.new(options)
28
+ when :rabbit_mq
29
+ require 'zipkin-tracer/zipkin_rabbit_mq_sender'
30
+ options = {
31
+ rabbit_mq_connection: config.rabbit_mq_connection,
32
+ rabbit_mq_exchange: config.rabbit_mq_exchange,
33
+ rabbit_mq_routing_key: config.rabbit_mq_routing_key,
34
+ async: config.async,
35
+ logger: config.logger
36
+ }
37
+ Trace::ZipkinRabbitMqSender.new(options)
28
38
  when :logger
29
39
  require 'zipkin-tracer/zipkin_logger_sender'
30
40
  Trace::ZipkinLoggerSender.new(logger: config.logger)
@@ -1,3 +1,3 @@
1
1
  module ZipkinTracer
2
- VERSION = '0.37.0'.freeze
2
+ VERSION = '0.38.0'.freeze
3
3
  end
@@ -0,0 +1,49 @@
1
+ require 'json'
2
+ require 'sucker_punch'
3
+ require 'zipkin-tracer/zipkin_sender_base'
4
+ require 'zipkin-tracer/hostname_resolver'
5
+
6
+ module Trace
7
+ class RabbitMqPublisher
8
+ include SuckerPunch::Job
9
+
10
+ def perform(exchange, routing_key, spans)
11
+ spans_with_ips = ::ZipkinTracer::HostnameResolver.new
12
+ .spans_with_ips(spans, ZipkinRabbitMqSender::IP_FORMAT)
13
+ .map(&:to_h)
14
+
15
+ message = JSON.generate(spans_with_ips)
16
+
17
+ exchange.publish(message, routing_key: routing_key)
18
+ rescue => e
19
+ SuckerPunch.logger.error(e)
20
+ end
21
+ end
22
+
23
+ # This class sends information to the Zipkin RabbitMQ Collector.
24
+ class ZipkinRabbitMqSender < ZipkinSenderBase
25
+ IP_FORMAT = :string
26
+ DEFAULT_EXCHANGE = ''
27
+ DEAFULT_ROUTING_KEY = 'zipkin'
28
+
29
+ def initialize(options)
30
+ connection = options[:rabbit_mq_connection]
31
+ channel = connection.create_channel
32
+ exchange_name = options[:rabbit_mq_exchange] || DEFAULT_EXCHANGE
33
+ @routing_key = options[:rabbit_mq_routing_key] || DEAFULT_ROUTING_KEY
34
+ @exchange = channel.exchange(exchange_name)
35
+ @async = options[:async] != false
36
+ SuckerPunch.logger = options[:logger]
37
+
38
+ super(options)
39
+ end
40
+
41
+ def flush!
42
+ if @async
43
+ RabbitMqPublisher.perform_async(@exchange, @routing_key, spans.dup)
44
+ else
45
+ RabbitMqPublisher.new.perform(@exchange, @routing_key, spans)
46
+ end
47
+ end
48
+ end
49
+ 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.37.0
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franklin Hu
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2019-05-30 00:00:00.000000000 Z
17
+ date: 2019-07-16 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: faraday
@@ -229,6 +229,7 @@ files:
229
229
  - lib/zipkin-tracer/zipkin_kafka_sender.rb
230
230
  - lib/zipkin-tracer/zipkin_logger_sender.rb
231
231
  - lib/zipkin-tracer/zipkin_null_sender.rb
232
+ - lib/zipkin-tracer/zipkin_rabbit_mq_sender.rb
232
233
  - lib/zipkin-tracer/zipkin_sender_base.rb
233
234
  - lib/zipkin-tracer/zipkin_sqs_sender.rb
234
235
  - zipkin-tracer.gemspec
@@ -253,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
254
  - !ruby/object:Gem::Version
254
255
  version: '0'
255
256
  requirements: []
256
- rubygems_version: 3.0.3
257
+ rubygems_version: 3.0.4
257
258
  signing_key:
258
259
  specification_version: 4
259
260
  summary: Ruby tracing via Zipkin