Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dalli multiplexing #823

Merged
merged 1 commit into from
Oct 1, 2019
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
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/dalli/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def tracer
end

def datadog_configuration
Datadog.configuration[:dalli]
Datadog.configuration[:dalli, "#{hostname}:#{port}"] || Datadog.configuration[:dalli]
end
end
end
Expand Down
30 changes: 29 additions & 1 deletion spec/ddtrace/contrib/dalli/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def all_spans
end

describe 'when a client calls #set' do
before(:each) do
before do
client.set('abc', 123)
try_wait_until { all_spans.any? }
end
Expand All @@ -55,4 +55,32 @@ def all_spans
expect(span.get_tag('out.port')).to eq(test_port)
end
end

describe 'when multiplexed configuration is provided' do
let(:service_name) { 'multiplex-service' }

before do
Datadog.configure do |c|
c.use :dalli, describes: "#{test_host}:#{test_port}", tracer: tracer, service_name: service_name
end
end

context 'and #set is called' do
before do
client.set('abc', 123)
try_wait_until { all_spans.any? }
end

it 'calls instrumentation' do
expect(all_spans.size).to eq(1)
expect(span.service).to eq(service_name)
expect(span.name).to eq('memcached.command')
expect(span.span_type).to eq('memcached')
expect(span.resource).to eq('SET')
expect(span.get_tag('memcached.command')).to eq('set abc 123 0 0')
expect(span.get_tag('out.host')).to eq(test_host)
expect(span.get_tag('out.port')).to eq(test_port)
end
end
end
end