Skip to content

Commit

Permalink
Environment variable service_name for mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Dec 6, 2022
1 parent 3a398b7 commit 6e70ec1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/datadog/tracing/contrib/mongodb/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ class Settings < Contrib::Configuration::Settings
end

option :quantize, default: DEFAULT_QUANTIZE
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/mongodb/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module MongoDB
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
module Ext
ENV_ENABLED = 'DD_TRACE_MONGO_ENABLED'.freeze
ENV_SERVICE_NAME = 'DD_TRACE_MONGO_SERVICE_NAME'.freeze
ENV_ANALYTICS_ENABLED = 'DD_TRACE_MONGO_ANALYTICS_ENABLED'.freeze
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_MONGO_ANALYTICS_SAMPLE_RATE'.freeze
DEFAULT_PEER_SERVICE_NAME = 'mongodb'.freeze
Expand Down
2 changes: 2 additions & 0 deletions spec/datadog/tracing/contrib/mongodb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'datadog/tracing/contrib/integration_examples'
require 'datadog/tracing/contrib/support/spec_helper'
require 'datadog/tracing/contrib/analytics_examples'
require 'datadog/tracing/contrib/environment_service_name_examples'

require 'ddtrace'
require 'mongo'
Expand Down Expand Up @@ -167,6 +168,7 @@
end

it_behaves_like 'measured span for integration', false
it_behaves_like 'environment service name', 'DD_TRACE_MONGO_SERVICE_NAME'
end

# Expects every value (except for keys) to be quantized.
Expand Down

0 comments on commit 6e70ec1

Please sign in to comment.