Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.0.0]
- Updates ddtrace to the 1.X line and uses that version's `Datadog::Tracer` syntax

## [0.1.0]

Expand Down
4 changes: 2 additions & 2 deletions datadog-queue-bus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Gem::Specification.new do |spec|
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
spec.require_paths = ['lib']

spec.add_dependency 'ddtrace', '~> 0.25'
spec.add_dependency 'ddtrace', '~> 1.0'
spec.add_dependency 'queue-bus', '~> 0.6'

spec.add_development_dependency 'bundler', '~> 1.17'
spec.add_development_dependency 'bundler', '~> 2.4'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.72'
Expand Down
7 changes: 4 additions & 3 deletions lib/datadog_queue_bus/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ def call(attrs)
resource += " event=#{event_type}" if event_type
resource += " sub=#{sub_key}" if sub_key

Datadog.tracer.trace('queue-bus.worker',
service: DatadogQueueBus.service_name,
resource: resource) do |span|
# def trace(name, continue_from: nil, **span_options, &block)
Datadog::Tracing.trace('queue-bus.worker',
service: DatadogQueueBus.service_name,
resource: resource) do |span|
attrs.keys.grep(/^bus_/).each do |key|
span.set_tag("queue-bus.#{key}", attrs[key])
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog_queue_bus/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module DatadogQueueBus
VERSION = '0.1.0'
VERSION = '1.0.0'
end
13 changes: 7 additions & 6 deletions spec/datadog_queue_bus/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
'bus_class_proxy' => 'QueueBus::Driver'
}
end
let(:tracer) { Datadog::Tracing }

it 'uses the class_proxy_class as the resource name' do
expect(Datadog.tracer)
expect(tracer)
.to receive(:trace)
.with('queue-bus.worker', hash_including(resource: 'QueueBus::Driver'))
subject.call(attrs)
Expand All @@ -27,7 +28,7 @@
end

it 'sends the service name' do
expect(Datadog.tracer)
expect(tracer)
.to receive(:trace)
.with('queue-bus.worker', hash_including(service: name))
subject.call(attrs)
Expand All @@ -40,7 +41,7 @@
end

it 'includes the event in the resource' do
expect(Datadog.tracer)
expect(tracer)
.to receive(:trace)
.with('queue-bus.worker',
hash_including(resource: a_string_matching(/event=my_event/)))
Expand All @@ -54,7 +55,7 @@
end

it 'includes the sub key in the resource name' do
expect(Datadog.tracer)
expect(tracer)
.to receive(:trace)
.with('queue-bus.worker',
hash_including(resource: a_string_matching(/sub=my_subscription/)))
Expand All @@ -69,7 +70,7 @@

it 'includes all attributes that start with bus_' do
span = spy('span')
expect(Datadog.tracer).to receive(:trace).and_yield(span)
expect(tracer).to receive(:trace).and_yield(span)
subject.call(attrs)
expect(span).to have_received(:set_tag).with('queue-bus.bus_class_proxy', 'QueueBus::Driver')
expect(span).to have_received(:set_tag).with('queue-bus.bus_field', 'my_field')
Expand All @@ -83,7 +84,7 @@

it 'includes all attributes that start with bus_' do
span = spy('span')
expect(Datadog.tracer).to receive(:trace).and_yield(span)
expect(tracer).to receive(:trace).and_yield(span)
subject.call(attrs)
expect(span).to have_received(:set_tag).with('queue-bus.bus_class_proxy', 'QueueBus::Driver')
expect(span).not_to have_received(:set_tag).with('queue-bus.user_id', 1234)
Expand Down