Skip to content

Commit

Permalink
Merge pull request #3056 from DataDog/conti/add-new-telemetry-configu…
Browse files Browse the repository at this point in the history
…rations
  • Loading branch information
marcotc authored Aug 17, 2023
2 parents acc02c7 + 25a6def commit d4d3cc9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/datadog/core/telemetry/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@ def application

# Forms a hash of standard key value pairs to be sent in the app-started event configuration
def configurations
config = Datadog.configuration
hash = {
DD_AGENT_HOST: Datadog.configuration.agent.host,
DD_AGENT_HOST: config.agent.host,
DD_AGENT_TRANSPORT: agent_transport,
DD_TRACE_SAMPLE_RATE: format_configuration_value(Datadog.configuration.tracing.sampling.default_rate),
DD_TRACE_SAMPLE_RATE: format_configuration_value(config.tracing.sampling.default_rate),
DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED: config.tracing.contrib.global_default_service_name.enabled
}
peer_service_mapping_str = ''
unless config.tracing.contrib.peer_service_mapping.empty?
peer_service_mapping = config.tracing.contrib.peer_service_mapping
peer_service_mapping_str = peer_service_mapping.map { |key, value| "#{key}:#{value}" }.join(',')
end
hash[:DD_TRACE_PEER_SERVICE_MAPPING] = peer_service_mapping_str
hash.compact!
hash
end
Expand Down
40 changes: 40 additions & 0 deletions spec/datadog/core/telemetry/collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,46 @@
it { is_expected.to_not include(:DD_TRACE_SAMPLE_RATE) }
end
end

context 'DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED' do
around do |example|
ClimateControl.modify(
DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED: dd_trace_remove_integration_service_names_enabled
) do
example.run
end
end

context 'when set to true' do
let(:dd_trace_remove_integration_service_names_enabled) { 'true' }
it { is_expected.to include(:DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED => true) }
end

context 'when nil defaults to false' do
let(:dd_trace_remove_integration_service_names_enabled) { nil }
it { is_expected.to include(:DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED => false) }
end
end

context 'DD_TRACE_PEER_SERVICE_MAPPING' do
around do |example|
ClimateControl.modify(
DD_TRACE_PEER_SERVICE_MAPPING: dd_trace_peer_service_mapping
) do
example.run
end
end

context 'when set' do
let(:dd_trace_peer_service_mapping) { 'key:value' }
it { is_expected.to include(:DD_TRACE_PEER_SERVICE_MAPPING => 'key:value') }
end

context 'when nil is blank' do
let(:dd_trace_peer_service_mapping) { nil }
it { is_expected.to include(:DD_TRACE_PEER_SERVICE_MAPPING => '') }
end
end
end

describe '#additional_payload' do
Expand Down

0 comments on commit d4d3cc9

Please sign in to comment.