Skip to content

Commit

Permalink
fix tests for peer service and ruboocop
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmustin committed Sep 8, 2020
1 parent e4e6cfd commit ecf4ca0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 1 addition & 3 deletions lib/ddtrace/contrib/ethon/easy_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module EasyPatch
def self.included(base)
base.send(:prepend, InstanceMethods)
end

# InstanceMethods - implementing instrumentation
# rubocop:disable Metrics/ModuleLength
module InstanceMethods
include Datadog::Contrib::HttpAnnotationHelper

Expand Down Expand Up @@ -104,10 +104,8 @@ def datadog_tag_request
method = @datadog_method.to_s
end
span.resource = method

# Tag as an external peer service
span.set_tag(Datadog::Ext::Integration::TAG_PEER_SERVICE, span.service)

# Set analytics sample rate
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?

Expand Down
4 changes: 1 addition & 3 deletions spec/ddtrace/contrib/excon/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@
expect(request_span.resource).to eq('GET')
end

<<<<<<< HEAD
it_behaves_like 'a peer service span'
=======

context 'and the host matches a specific configuration' do
before do
Datadog.configure do |c|
Expand All @@ -186,7 +185,6 @@
expect(request_span.service).to eq('bar')
end
end
>>>>>>> master
end

context 'default request headers' do
Expand Down
21 changes: 17 additions & 4 deletions spec/ddtrace/contrib/sequel/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ def perform_query!

context 'only with defaults' do
# Expect it to be the normalized adapter name.
it do
before do
Datadog.configure { |c| c.use :sequel }
perform_query!
end

it do
expect(span.service).to eq('sqlite')
end

Expand All @@ -51,9 +54,12 @@ def perform_query!
context 'with options set via #use' do
let(:service_name) { 'my-sequel' }

it do
before do
Datadog.configure { |c| c.use :sequel, service_name: service_name }
perform_query!
end

it do
expect(span.service).to eq(service_name)
end

Expand All @@ -63,10 +69,14 @@ def perform_query!
context 'with options set on Sequel::Database' do
let(:service_name) { 'custom-sequel' }

it do
before do
Datadog.configure { |c| c.use :sequel }
Datadog.configure(sequel, service_name: service_name)
Datadog.configure { |c| c.use :sequel }
perform_query!
end

it do
expect(span.service).to eq(service_name)
end

Expand All @@ -77,10 +87,13 @@ def perform_query!
# NOTE: This test really only works when run in isolation.
# It relies on Sequel not being patched, and there's
# no way to unpatch it once its happened in other tests.
it do
before do
sequel
Datadog.configure { |c| c.use :sequel }
perform_query!
end

it do
expect(span.service).to eq('sqlite')
end

Expand Down

0 comments on commit ecf4ca0

Please sign in to comment.