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

Auto-instrumentation with service_name from environmental variable #2455

Merged
merged 19 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Environment variable service_name for dalli
  • Loading branch information
TonyCTHsu committed Dec 6, 2022
commit baf298ca688d5915a3b8c123d87281e4de17073d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ class Settings < Contrib::Configuration::Settings
o.lazy
end

option :service_name, default: Ext::DEFAULT_PEER_SERVICE_NAME
option :service_name do |o|
o.default do
ENV.fetch(Ext::ENV_SERVICE_NAME) do
Ext::DEFAULT_PEER_SERVICE_NAME
end
end
o.lazy
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/dalli/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Ext
ENV_ENABLED = 'DD_TRACE_DALLI_ENABLED'.freeze
ENV_ANALYTICS_ENABLED = 'DD_TRACE_DALLI_ANALYTICS_ENABLED'.freeze
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_DALLI_ANALYTICS_SAMPLE_RATE'.freeze
ENV_SERVICE_NAME = 'DD_TRACE_DALLI_SERVICE_NAME'.freeze
QUANTIZE_MAX_CMD_LENGTH = 100
DEFAULT_PEER_SERVICE_NAME = 'memcached'.freeze
SPAN_COMMAND = 'memcached.command'.freeze
Expand Down
8 changes: 8 additions & 0 deletions spec/datadog/tracing/contrib/dalli/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'datadog/tracing/contrib/support/spec_helper'
require 'datadog/tracing/contrib/analytics_examples'
require 'datadog/tracing/contrib/integration_examples'
require 'datadog/tracing/contrib/environment_service_name_examples'

require 'dalli'
require 'ddtrace'
Expand All @@ -29,6 +30,13 @@
Datadog.registry[:dalli].reset_configuration!
end

it_behaves_like 'environment service name', 'DD_TRACE_DALLI_SERVICE_NAME' do
subject do
client.set('abc', 123)
try_wait_until { fetch_spans.any? }
end
end

describe 'when a client calls #set' do
before do
client.set('abc', 123)
Expand Down