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 mongodb
  • Loading branch information
TonyCTHsu committed Dec 6, 2022
commit 6e70ec1df94adbb4ca13c4bdcb9b572af7f62062
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