Skip to content

Commit

Permalink
option :async is not passed to http sender (#167)
Browse files Browse the repository at this point in the history
* option :async is not passed to http sender

* add specs to ensure that switch case statement passes the expected options
  • Loading branch information
turnon authored and jcarres-mdsol committed Oct 25, 2019
1 parent 0a8be52 commit 79c9980
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/zipkin-tracer/tracer_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ def tracer(config)
tracer = case adapter
when :json
require 'zipkin-tracer/zipkin_http_sender'
options = { json_api_host: config.json_api_host, logger: config.logger }
options = {
async: config.async,
json_api_host: config.json_api_host,
logger: config.logger
}
Trace::ZipkinHttpSender.new(options)
when :kafka
require 'zipkin-tracer/zipkin_kafka_sender'
Expand Down
2 changes: 1 addition & 1 deletion lib/zipkin-tracer/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ZipkinTracer
VERSION = '0.40.0'.freeze
VERSION = '0.40.1'.freeze
end
17 changes: 14 additions & 3 deletions spec/lib/tracer_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ def middleware(app, config={})
described_class.new(app, configuration)
end

def configuration(options)
ZipkinTracer::Config.new(nil, options)
end
def configuration(options)
ZipkinTracer::Config.new(nil, options)
end

def should_read_config(*attrs)
attrs.each do |attr|
expect(config).to receive(attr)
end
end

let(:logger) { Logger.new(nil) }
let(:subject) { described_class.new(config) }
Expand All @@ -35,6 +41,7 @@ def configuration(options)
let(:config) { configuration(zookeeper: zookeeper) }

it 'creates a zipkin kafka sender' do
should_read_config(:zookeeper)
allow(Trace::ZipkinKafkaSender).to receive(:new) { tracer }
expect(Trace).to receive(:tracer=).with(tracer)
expect(described_class.new.tracer(config)).to eq(tracer)
Expand All @@ -46,6 +53,7 @@ def configuration(options)
let(:config) { configuration(json_api_host: 'fake_json_api_host') }

it 'creates a zipkin json tracer' do
should_read_config(:async, :json_api_host, :logger)
allow(Trace::ZipkinHttpSender).to receive(:new) { tracer }
expect(Trace).to receive(:tracer=).with(tracer)
expect(described_class.new.tracer(config)).to eq(tracer)
Expand All @@ -56,6 +64,7 @@ def configuration(options)
let(:config) { configuration(log_tracing: true) }

it 'creates a logger tracer' do
should_read_config(:logger)
allow(Trace::ZipkinLoggerSender).to receive(:new) { tracer }
expect(Trace).to receive(:tracer=).with(tracer)
expect(described_class.new.tracer(config)).to eq(tracer)
Expand All @@ -66,6 +75,7 @@ def configuration(options)
let(:config) { configuration(sqs_queue_name: 'zipkin-sqs') }

it 'creates a sqs tracer' do
should_read_config(:async, :logger, :sqs_queue_name, :sqs_region)
allow(Trace::ZipkinSqsSender).to receive(:new) { tracer }
expect(Trace).to receive(:tracer=).with(tracer)
expect(described_class.new.tracer(config)).to eq(tracer)
Expand All @@ -77,6 +87,7 @@ def configuration(options)
let(:config) { configuration(rabbit_mq_connection: connection) }

it 'creates a rabbit mq tracer' do
should_read_config(:rabbit_mq_connection, :rabbit_mq_exchange, :rabbit_mq_routing_key, :async, :logger)
allow(Trace::ZipkinRabbitMqSender).to receive(:new) { tracer }
expect(Trace).to receive(:tracer=).with(tracer)
expect(described_class.new.tracer(config)).to eq(tracer)
Expand Down

0 comments on commit 79c9980

Please sign in to comment.