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 httprb
  • Loading branch information
TonyCTHsu committed Dec 6, 2022
commit 3a398b7d963e246157c27da37be8f46be017f854
11 changes: 10 additions & 1 deletion lib/datadog/tracing/contrib/httprb/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ class Settings < Contrib::Configuration::Settings
end

option :distributed_tracing, default: true
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

option :split_by_domain, default: false
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/httprb/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Httprb
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
module Ext
ENV_ENABLED = 'DD_TRACE_HTTPRB_ENABLED'.freeze
ENV_SERVICE_NAME = 'DD_TRACE_HTTPRB_SERVICE_NAME'.freeze
ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPRB_ANALYTICS_ENABLED'.freeze
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_EHTTPRB_ANALYTICS_SAMPLE_RATE'.freeze
DEFAULT_PEER_SERVICE_NAME = 'httprb'.freeze
Expand Down
7 changes: 7 additions & 0 deletions spec/datadog/tracing/contrib/httprb/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'datadog/tracing/contrib/analytics_examples'
require 'datadog/tracing/contrib/integration_examples'
require 'datadog/tracing/contrib/support/spec_helper'
require 'datadog/tracing/contrib/environment_service_name_examples'
require 'spec/support/thread_helpers'

RSpec.describe Datadog::Tracing::Contrib::Httprb::Instrumentation do
Expand Down Expand Up @@ -146,6 +147,8 @@
let(:analytics_enabled_var) { Datadog::Tracing::Contrib::Httprb::Ext::ENV_ANALYTICS_ENABLED }
let(:analytics_sample_rate_var) { Datadog::Tracing::Contrib::Httprb::Ext::ENV_ANALYTICS_SAMPLE_RATE }
end

it_behaves_like 'environment service name', 'DD_TRACE_HTTPRB_SERVICE_NAME'
end

context 'response has internal server error status' do
Expand All @@ -170,6 +173,8 @@
it 'has error message' do
expect(span).to have_error_message('Error')
end

it_behaves_like 'environment service name', 'DD_TRACE_HTTPRB_SERVICE_NAME'
end

context 'response has not found status' do
Expand All @@ -194,6 +199,8 @@
it 'has error message' do
expect(span).to have_error_message('Error')
end

it_behaves_like 'environment service name', 'DD_TRACE_HTTPRB_SERVICE_NAME'
end

context 'distributed tracing default' do
Expand Down