From 1554aef19c00ec016b53f2bad5bd9de71a734de2 Mon Sep 17 00:00:00 2001 From: Marco Costa Date: Fri, 15 Dec 2023 14:02:51 -0800 Subject: [PATCH] Remove distributed_tracing option namespacing --- docs/GettingStarted.md | 12 +- lib/datadog/core/telemetry/collector.rb | 4 +- lib/datadog/tracing/configuration/settings.rb | 143 +++++------ .../tracing/distributed/propagation.rb | 12 +- sig/datadog/core/telemetry/collector.rbs | 2 +- spec/datadog/opentelemetry_spec.rb | 4 +- .../opentracer/rack_propagator_spec.rb | 2 +- .../tracing/configuration/settings_spec.rb | 237 +++++++++--------- .../grpc/distributed/propagation_spec.rb | 10 +- .../http/distributed/propagation_spec.rb | 10 +- .../tracing/distributed/propagation_spec.rb | 4 +- .../tracing/tracer_integration_spec.rb | 4 +- 12 files changed, 216 insertions(+), 228 deletions(-) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 52ca6f52739..f8c3f1f36dd 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -2062,10 +2062,10 @@ For example, if `tracing.sampling.default_rate` is configured by [Remote Configu | `tracing.analytics.enabled` | `DD_TRACE_ANALYTICS_ENABLED` | `nil` | Enables or disables trace analytics. See [Sampling](#sampling) for more details. | | `tracing.contrib.peer_service_mapping` | `DD_TRACE_PEER_SERVICE_MAPPING` | `nil` | Defines remapping of `peer.service` tag across all instrumentation. Provide a list of `old_value1:new_value1, old_value2:new_value2, ...` | | `tracing.contrib.global_default_service_name.enabled` | `DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED` | `false` | Changes the default value for `service_name` to the application service name across all instrumentation | -| `tracing.distributed_tracing.propagation_extract_first` | `DD_TRACE_PROPAGATION_EXTRACT_FIRST` | `false` | Exit immediately on the first valid propagation format detected. See [Distributed Tracing](#distributed-tracing) for more details. | -| `tracing.distributed_tracing.propagation_extract_style` | `DD_TRACE_PROPAGATION_STYLE_EXTRACT` | `['Datadog','tracecontext']` | Distributed tracing propagation formats to extract. Overrides `DD_TRACE_PROPAGATION_STYLE`. See [Distributed Tracing](#distributed-tracing) for more details. | -| `tracing.distributed_tracing.propagation_inject_style` | `DD_TRACE_PROPAGATION_STYLE_INJECT` | `['Datadog','tracecontext']` | Distributed tracing propagation formats to inject. Overrides `DD_TRACE_PROPAGATION_STYLE`. See [Distributed Tracing](#distributed-tracing) for more details. | -| `tracing.distributed_tracing.propagation_style` | `DD_TRACE_PROPAGATION_STYLE` | `nil` | Distributed tracing propagation formats to extract and inject. See [Distributed Tracing](#distributed-tracing) for more details. | +| `tracing.propagation_extract_first` | `DD_TRACE_PROPAGATION_EXTRACT_FIRST` | `false` | Exit immediately on the first valid propagation format detected. See [Distributed Tracing](#distributed-tracing) for more details. | +| `tracing.propagation_style_extract` | `DD_TRACE_PROPAGATION_STYLE_EXTRACT` | `['Datadog','tracecontext']` | Distributed tracing propagation formats to extract. Overrides `DD_TRACE_PROPAGATION_STYLE`. See [Distributed Tracing](#distributed-tracing) for more details. | +| `tracing.propagation_style_inject` | `DD_TRACE_PROPAGATION_STYLE_INJECT` | `['Datadog','tracecontext']` | Distributed tracing propagation formats to inject. Overrides `DD_TRACE_PROPAGATION_STYLE`. See [Distributed Tracing](#distributed-tracing) for more details. | +| `tracing.propagation_style` | `DD_TRACE_PROPAGATION_STYLE` | `nil` | Distributed tracing propagation formats to extract and inject. See [Distributed Tracing](#distributed-tracing) for more details. | | `tracing.enabled` | `DD_TRACE_ENABLED` | `true` | Enables or disables tracing. If set to `false` instrumentation will still run, but no traces are sent to the trace agent. | | `tracing.header_tags` | `DD_TRACE_HEADER_TAGS` | `nil` | Record HTTP headers as span tags. See [Applying header tags to root spans][header tags] for more information. | | `tracing.instrument(, )` | | | Activates instrumentation for a specific library. See [Integration instrumentation](#integration-instrumentation) for more details. | @@ -2350,10 +2350,10 @@ You can enable/disable the use of these formats via `Datadog.configure`: ```ruby Datadog.configure do |c| # List of header formats that should be extracted - c.tracing.distributed_tracing.propagation_extract_style = [ 'tracecontext', 'Datadog', 'b3' ] + c.tracing.propagation_style_extract = [ 'tracecontext', 'Datadog', 'b3' ] # List of header formats that should be injected - c.tracing.distributed_tracing.propagation_inject_style = [ 'tracecontext', 'Datadog' ] + c.tracing.propagation_style_inject = [ 'tracecontext', 'Datadog' ] end ``` diff --git a/lib/datadog/core/telemetry/collector.rb b/lib/datadog/core/telemetry/collector.rb index adfa4173539..b472ccf8b08 100644 --- a/lib/datadog/core/telemetry/collector.rb +++ b/lib/datadog/core/telemetry/collector.rb @@ -117,8 +117,8 @@ def tracer_time 'profiling.enabled', 'runtime_metrics.enabled', 'tracing.analytics.enabled', - 'tracing.distributed_tracing.propagation_inject_style', - 'tracing.distributed_tracing.propagation_extract_style', + 'tracing.propagation_style_inject', + 'tracing.propagation_style_extract', 'tracing.enabled', 'tracing.log_injection', 'tracing.partial_flush.enabled', diff --git a/lib/datadog/tracing/configuration/settings.rb b/lib/datadog/tracing/configuration/settings.rb index 558af6497ba..1fc9c5abc3b 100644 --- a/lib/datadog/tracing/configuration/settings.rb +++ b/lib/datadog/tracing/configuration/settings.rb @@ -32,95 +32,84 @@ def self.extended(base) end end - # [Distributed Tracing](https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#distributed-tracing) propagation - # style configuration. + # An ordered, case-insensitive list of what data propagation styles the tracer will use to extract distributed tracing propagation + # data from incoming requests and messages. # - # The supported formats are: - # * `Datadog`: Datadog propagation format, described by [Distributed Tracing](https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#distributed-tracing). - # * `b3multi`: B3 Propagation using multiple headers, described by [openzipkin/b3-propagation](https://github.com/openzipkin/b3-propagation#multiple-headers). - # * `b3`: B3 Propagation using a single header, described by [openzipkin/b3-propagation](https://github.com/openzipkin/b3-propagation#single-header). + # The tracer will try to find distributed headers in the order they are present in the list provided to this option. + # The first format to have valid data present will be used. # - # @public_api - settings :distributed_tracing do - # An ordered, case-insensitive list of what data propagation styles the tracer will use to extract distributed tracing propagation - # data from incoming requests and messages. - # - # The tracer will try to find distributed headers in the order they are present in the list provided to this option. - # The first format to have valid data present will be used. - # - # @default `DD_TRACE_PROPAGATION_STYLE_EXTRACT` environment variable (comma-separated list), - # otherwise `['datadog','b3multi','b3']`. - # @return [Array] - option :propagation_extract_style do |o| - o.type :array - o.env Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_EXTRACT - o.default( - [ - Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, - Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT, - ] - ) - o.after_set do |styles| - # Make values case-insensitive - styles.map!(&:downcase) - end - end - - # The case-insensitive list of the data propagation styles the tracer will use to inject distributed tracing propagation - # data into outgoing requests and messages. - # - # The tracer will inject data from all styles specified in this option. - # - # @default `DD_TRACE_PROPAGATION_STYLE_INJECT` environment variable (comma-separated list), otherwise `['datadog','tracecontext']`. - # @return [Array] - option :propagation_inject_style do |o| - o.type :array - o.env Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_INJECT - o.default [ + # @default `DD_TRACE_PROPAGATION_STYLE_EXTRACT` environment variable (comma-separated list), + # otherwise `['datadog','b3multi','b3']`. + # @return [Array] + option :propagation_style_extract do |o| + o.type :array + o.env Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_EXTRACT + o.default( + [ Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT, ] - o.after_set do |styles| - # Make values case-insensitive - styles.map!(&:downcase) - end + ) + o.after_set do |styles| + # Make values case-insensitive + styles.map!(&:downcase) end + end - # An ordered, case-insensitive list of what data propagation styles the tracer will use to extract distributed tracing propagation - # data from incoming requests and inject into outgoing requests. - # - # This configuration is the equivalent of configuring both {propagation_extract_style} - # {propagation_inject_style} to value set to {propagation_style}. - # - # @default `DD_TRACE_PROPAGATION_STYLE` environment variable (comma-separated list). - # @return [Array] - option :propagation_style do |o| - o.type :array - o.env Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE - o.default [] - o.after_set do |styles| - next if styles.empty? - - # Make values case-insensitive - styles.map!(&:downcase) - - set_option(:propagation_extract_style, styles) - set_option(:propagation_inject_style, styles) - end + # The case-insensitive list of the data propagation styles the tracer will use to inject distributed tracing propagation + # data into outgoing requests and messages. + # + # The tracer will inject data from all styles specified in this option. + # + # @default `DD_TRACE_PROPAGATION_STYLE_INJECT` environment variable (comma-separated list), otherwise `['datadog','tracecontext']`. + # @return [Array] + option :propagation_style_inject do |o| + o.type :array + o.env Tracing::Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE_INJECT + o.default [ + Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, + Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT, + ] + o.after_set do |styles| + # Make values case-insensitive + styles.map!(&:downcase) end + end - # Strictly stop at the first successfully serialized style. - # This prevents the tracer from enriching the extracted context with information from - # other valid propagations styles present in the request. - # @default `DD_TRACE_PROPAGATION_EXTRACT_FIRST` environment variable, otherwise `false`. - # @return [Boolean] - option :propagation_extract_first do |o| - o.env Tracing::Configuration::Ext::Distributed::EXTRACT_FIRST - o.default false - o.type :bool + # An ordered, case-insensitive list of what data propagation styles the tracer will use to extract distributed tracing propagation + # data from incoming requests and inject into outgoing requests. + # + # This configuration is the equivalent of configuring both {propagation_style_extract} + # {propagation_style_inject} to value set to {propagation_style}. + # + # @default `DD_TRACE_PROPAGATION_STYLE` environment variable (comma-separated list). + # @return [Array] + option :propagation_style do |o| + o.type :array + o.env Configuration::Ext::Distributed::ENV_PROPAGATION_STYLE + o.default [] + o.after_set do |styles| + next if styles.empty? + + # Make values case-insensitive + styles.map!(&:downcase) + + set_option(:propagation_style_extract, styles) + set_option(:propagation_style_inject, styles) end end + # Strictly stop at the first successfully serialized style. + # This prevents the tracer from enriching the extracted context with information from + # other valid propagations styles present in the request. + # @default `DD_TRACE_PROPAGATION_EXTRACT_FIRST` environment variable, otherwise `false`. + # @return [Boolean] + option :propagation_extract_first do |o| + o.env Tracing::Configuration::Ext::Distributed::EXTRACT_FIRST + o.default false + o.type :bool + end + # Enable trace collection and span generation. # # You can use this option to disable tracing without having to diff --git a/lib/datadog/tracing/distributed/propagation.rb b/lib/datadog/tracing/distributed/propagation.rb index 1e007417b2d..421764dcf12 100644 --- a/lib/datadog/tracing/distributed/propagation.rb +++ b/lib/datadog/tracing/distributed/propagation.rb @@ -10,7 +10,7 @@ module Distributed # Provides extraction and injection of distributed trace data. class Propagation # DEV: This class should receive the value for - # DEV: `Datadog.configuration.tracing.distributed_tracing.propagation_inject_style` + # DEV: `Datadog.configuration.tracing.propagation_style_inject` # DEV: at initialization time, instead of constantly reading global values. # DEV: This means this class should be reconfigured on `Datadog.configure` calls, thus # DEV: singleton instances should not used as they will become stale. @@ -20,10 +20,10 @@ def initialize(propagation_styles:) @propagation_styles = propagation_styles # We need to make sure propagation_style option is evaluated. # Our options are lazy evaluated and it happens that propagation_style has the after_set callback - # that affect Datadog.configuration.tracing.distributed_tracing.propagation_inject_style and - # Datadog.configuration.tracing.distributed_tracing.propagation_extract_style + # that affect Datadog.configuration.tracing.propagation_style_inject and + # Datadog.configuration.tracing.propagation_style_extract # By calling it here, we make sure if the customers has set any value either via code or ENV variable is applied. - ::Datadog.configuration.tracing.distributed_tracing.propagation_style + ::Datadog.configuration.tracing.propagation_style end # inject! populates the env with span ID, trace ID and sampling priority @@ -53,7 +53,7 @@ def inject!(digest, data) result = false # Inject all configured propagation styles - ::Datadog.configuration.tracing.distributed_tracing.propagation_inject_style.each do |style| + ::Datadog.configuration.tracing.propagation_style_inject.each do |style| propagator = @propagation_styles[style] begin if propagator @@ -85,7 +85,7 @@ def extract(data) config = ::Datadog.configuration.tracing.distributed_tracing - config.propagation_extract_style.each do |style| + config.propagation_style_extract.each do |style| propagator = @propagation_styles[style] next if propagator.nil? diff --git a/sig/datadog/core/telemetry/collector.rbs b/sig/datadog/core/telemetry/collector.rbs index a01d736d65e..04f05d28535 100644 --- a/sig/datadog/core/telemetry/collector.rbs +++ b/sig/datadog/core/telemetry/collector.rbs @@ -14,7 +14,7 @@ module Datadog private - TARGET_OPTIONS: ::Array["ci.enabled" | "logger.level" | "profiling.advanced.code_provenance_enabled" | "profiling.advanced.endpoint.collection.enabled" | "profiling.enabled" | "runtime_metrics.enabled" | "tracing.analytics.enabled" | "tracing.distributed_tracing.propagation_inject_style" | "tracing.distributed_tracing.propagation_extract_style" | "tracing.enabled" | "tracing.log_injection" | "tracing.partial_flush.enabled" | "tracing.partial_flush.min_spans_threshold" | "tracing.priority_sampling" | "tracing.report_hostname" | "tracing.sampling.default_rate" | "tracing.sampling.rate_limit"] + TARGET_OPTIONS: ::Array["ci.enabled" | "logger.level" | "profiling.advanced.code_provenance_enabled" | "profiling.advanced.endpoint.collection.enabled" | "profiling.enabled" | "runtime_metrics.enabled" | "tracing.analytics.enabled" | "tracing.propagation_style_inject" | "tracing.propagation_style_extract" | "tracing.enabled" | "tracing.log_injection" | "tracing.partial_flush.enabled" | "tracing.partial_flush.min_spans_threshold" | "tracing.priority_sampling" | "tracing.report_hostname" | "tracing.sampling.default_rate" | "tracing.sampling.rate_limit"] def additional_payload_variables: () -> untyped diff --git a/spec/datadog/opentelemetry_spec.rb b/spec/datadog/opentelemetry_spec.rb index 51b2740d370..c332b4dcc88 100644 --- a/spec/datadog/opentelemetry_spec.rb +++ b/spec/datadog/opentelemetry_spec.rb @@ -16,7 +16,7 @@ Datadog.configure do |c| c.tracing.writer = writer_ c.tracing.partial_flush.min_spans_threshold = 1 # Ensure tests flush spans quickly - c.tracing.distributed_tracing.propagation_style = ['datadog'] # Ensure test has consistent propagation configuration + c.tracing.propagation_style = ['datadog'] # Ensure test has consistent propagation configuration end ::OpenTelemetry::SDK.configure do |c| @@ -732,7 +732,7 @@ def headers before do Datadog.configure do |c| - c.tracing.distributed_tracing.propagation_extract_style = ['datadog', 'tracecontext'] + c.tracing.propagation_style_extract = ['datadog', 'tracecontext'] end end diff --git a/spec/datadog/opentracer/rack_propagator_spec.rb b/spec/datadog/opentracer/rack_propagator_spec.rb index 4a1b22dfb2b..20db316e753 100644 --- a/spec/datadog/opentracer/rack_propagator_spec.rb +++ b/spec/datadog/opentracer/rack_propagator_spec.rb @@ -24,7 +24,7 @@ before do Datadog.configure do |c| - c.tracing.distributed_tracing.propagation_style = ['datadog'] + c.tracing.propagation_style = ['datadog'] end # Expect carrier to be set with Datadog trace properties diff --git a/spec/datadog/tracing/configuration/settings_spec.rb b/spec/datadog/tracing/configuration/settings_spec.rb index 647b26322be..9fb781917a3 100644 --- a/spec/datadog/tracing/configuration/settings_spec.rb +++ b/spec/datadog/tracing/configuration/settings_spec.rb @@ -18,6 +18,13 @@ let(:options) { {} } describe '#tracing' do + let(:var_value) { nil } + let(:var_name) { '_test_' } + around do |example| + ClimateControl.modify(var_name => var_value) do + example.run + end + end describe '#analytics' do describe '#enabled' do subject(:enabled) { settings.tracing.analytics.enabled } @@ -57,34 +64,39 @@ end end - describe '#distributed_tracing' do - around do |example| - ClimateControl.modify(var_name => var_value) do - example.run - end - end + describe '#propagation_style_extract' do + subject(:propagation_style_extract) { settings.tracing.propagation_style_extract } - describe '#propagation_extract_style' do - subject(:propagation_extract_style) { settings.tracing.distributed_tracing.propagation_extract_style } + context 'when DD_TRACE_PROPAGATION_STYLE_EXTRACT' do + let(:var_name) { 'DD_TRACE_PROPAGATION_STYLE_EXTRACT' } - context 'when DD_TRACE_PROPAGATION_STYLE_EXTRACT' do - let(:var_name) { 'DD_TRACE_PROPAGATION_STYLE_EXTRACT' } + context 'is not defined' do + let(:var_value) { nil } - context 'is not defined' do - let(:var_value) { nil } + it do + is_expected.to contain_exactly( + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT + ) + end + end - it do - is_expected.to contain_exactly( - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT - ) - end + context 'is defined' do + let(:var_value) { 'b3multi,b3' } + + it do + is_expected.to eq( + [ + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER, + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER + ] + ) end - context 'is defined' do - let(:var_value) { 'b3multi,b3' } + context 'with a mixed case value' do + let(:var_value) { 'B3Multi,B3' } - it do + it 'parses in a case-insensitive manner' do is_expected.to eq( [ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER, @@ -92,44 +104,44 @@ ] ) end - - context 'with a mixed case value' do - let(:var_value) { 'B3Multi,B3' } - - it 'parses in a case-insensitive manner' do - is_expected.to eq( - [ - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_MULTI_HEADER, - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER - ] - ) - end - end end end end + end - describe '#propagation_inject_style' do - subject(:propagation_inject_style) { settings.tracing.distributed_tracing.propagation_inject_style } + describe '#propagation_style_inject' do + subject(:propagation_style_inject) { settings.tracing.propagation_style_inject } - context 'with DD_TRACE_PROPAGATION_STYLE_INJECT' do - let(:var_name) { 'DD_TRACE_PROPAGATION_STYLE_INJECT' } + context 'with DD_TRACE_PROPAGATION_STYLE_INJECT' do + let(:var_name) { 'DD_TRACE_PROPAGATION_STYLE_INJECT' } - context 'is not defined' do - let(:var_value) { nil } + context 'is not defined' do + let(:var_value) { nil } - it do - is_expected.to contain_exactly( + it do + is_expected.to contain_exactly( + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT + ) + end + end + + context 'is defined' do + let(:var_value) { 'datadog,b3' } + + it do + is_expected.to eq( + [ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT - ) - end + Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER + ] + ) end - context 'is defined' do - let(:var_value) { 'datadog,b3' } + context 'with a mixed case value' do + let(:var_value) { 'Datadog,B3' } - it do + it 'parses in a case-insensitive manner' do is_expected.to eq( [ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, @@ -137,109 +149,96 @@ ] ) end - - context 'with a mixed case value' do - let(:var_value) { 'Datadog,B3' } - - it 'parses in a case-insensitive manner' do - is_expected.to eq( - [ - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG, - Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER - ] - ) - end - end end end end + end - describe '#propagation_style' do - subject(:propagation_style) { settings.tracing.distributed_tracing.propagation_style } + describe '#propagation_style' do + subject(:propagation_style) { settings.tracing.propagation_style } - def propagation_extract_style - settings.tracing.distributed_tracing.propagation_extract_style - end + def propagation_style_extract + settings.tracing.propagation_style_extract + end - def propagation_inject_style - settings.tracing.distributed_tracing.propagation_inject_style - end + def propagation_style_inject + settings.tracing.propagation_style_inject + end - context 'with DD_TRACE_PROPAGATION_STYLE' do - let(:var_name) { 'DD_TRACE_PROPAGATION_STYLE' } + context 'with DD_TRACE_PROPAGATION_STYLE' do + let(:var_name) { 'DD_TRACE_PROPAGATION_STYLE' } - context 'is not defined' do - let(:var_value) { nil } + context 'is not defined' do + let(:var_value) { nil } - it { is_expected.to eq [] } + it { is_expected.to eq [] } - it 'does not change propagation_extract_style' do - expect { propagation_style }.to_not change { propagation_extract_style }.from(%w[datadog tracecontext]) - end + it 'does not change propagation_style_extract' do + expect { propagation_style }.to_not change { propagation_style_extract }.from(%w[datadog tracecontext]) + end - it 'does not change propagation_inject_style' do - expect { propagation_style }.to_not change { propagation_inject_style }.from(%w[datadog tracecontext]) - end + it 'does not change propagation_style_inject' do + expect { propagation_style }.to_not change { propagation_style_inject }.from(%w[datadog tracecontext]) end + end - context 'is defined' do - let(:var_value) { 'b3multi,b3' } + context 'is defined' do + let(:var_value) { 'b3multi,b3' } - it { is_expected.to contain_exactly('b3multi', 'b3') } + it { is_expected.to contain_exactly('b3multi', 'b3') } - it 'sets propagation_extract_style' do - expect { propagation_style }.to change { propagation_extract_style }.to(%w[b3multi b3]) - end + it 'sets propagation_style_extract' do + expect { propagation_style }.to change { propagation_style_extract }.to(%w[b3multi b3]) + end - it 'sets propagation_inject_style' do - expect { propagation_style }.to change { propagation_inject_style }.to(%w[b3multi b3]) - end + it 'sets propagation_style_inject' do + expect { propagation_style }.to change { propagation_style_inject }.to(%w[b3multi b3]) + end - context 'with a mixed case value' do - let(:var_value) { 'b3MULTI' } + context 'with a mixed case value' do + let(:var_value) { 'b3MULTI' } - it 'parses in a case-insensitive manner' do - expect { propagation_style }.to change { propagation_extract_style }.to(%w[b3multi]) - end + it 'parses in a case-insensitive manner' do + expect { propagation_style }.to change { propagation_style_extract }.to(%w[b3multi]) end end end end + end - describe '#propagation_extract_first' do - subject(:propagation_extract_first) { settings.tracing.distributed_tracing.propagation_extract_first } + describe '#propagation_extract_first' do + subject(:propagation_extract_first) { settings.tracing.propagation_extract_first } - let(:var_value) { nil } - let(:var_name) { 'DD_TRACE_PROPAGATION_EXTRACT_FIRST' } - it { is_expected.to be false } + let(:var_value) { nil } + let(:var_name) { 'DD_TRACE_PROPAGATION_EXTRACT_FIRST' } + it { is_expected.to be false } - context 'when DD_TRACE_PROPAGATION_EXTRACT_FIRST' do - context 'is not defined' do - let(:var_value) { nil } + context 'when DD_TRACE_PROPAGATION_EXTRACT_FIRST' do + context 'is not defined' do + let(:var_value) { nil } - it { is_expected.to be false } - end + it { is_expected.to be false } + end - context 'is set to true' do - let(:var_value) { 'true' } + context 'is set to true' do + let(:var_value) { 'true' } - it { is_expected.to be true } - end + it { is_expected.to be true } + end - context 'is set to false' do - let(:var_value) { 'false' } + context 'is set to false' do + let(:var_value) { 'false' } - it { is_expected.to be false } - end + it { is_expected.to be false } end + end - describe '#propagation_extract_first=' do - it 'updates the #propagation_extract_first setting' do - expect { settings.tracing.distributed_tracing.propagation_extract_first = true } - .to change { settings.tracing.distributed_tracing.propagation_extract_first } - .from(false) - .to(true) - end + describe '#propagation_extract_first=' do + it 'updates the #propagation_extract_first setting' do + expect { settings.tracing.propagation_extract_first = true } + .to change { settings.tracing.propagation_extract_first } + .from(false) + .to(true) end end end diff --git a/spec/datadog/tracing/contrib/grpc/distributed/propagation_spec.rb b/spec/datadog/tracing/contrib/grpc/distributed/propagation_spec.rb index aac699d71c1..2695feb63e2 100644 --- a/spec/datadog/tracing/contrib/grpc/distributed/propagation_spec.rb +++ b/spec/datadog/tracing/contrib/grpc/distributed/propagation_spec.rb @@ -40,35 +40,35 @@ context 'for B3 Multi' do it_behaves_like 'B3 Multi distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['b3multi'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['b3multi'] } } let(:b3) { propagation } end end context 'for B3 Single' do it_behaves_like 'B3 Single distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['b3'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['b3'] } } let(:b3_single) { propagation } end end context 'for Datadog' do it_behaves_like 'Datadog distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['datadog'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['datadog'] } } let(:datadog) { propagation } end end context 'for Trace Context' do it_behaves_like 'Trace Context distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['tracecontext'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['tracecontext'] } } let(:datadog) { propagation } end end context 'for None' do it_behaves_like 'None distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['none'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['none'] } } let(:datadog) { propagation } end end diff --git a/spec/datadog/tracing/contrib/http/distributed/propagation_spec.rb b/spec/datadog/tracing/contrib/http/distributed/propagation_spec.rb index 3e9b6f01fa1..092d1f3d527 100644 --- a/spec/datadog/tracing/contrib/http/distributed/propagation_spec.rb +++ b/spec/datadog/tracing/contrib/http/distributed/propagation_spec.rb @@ -25,35 +25,35 @@ context 'for B3 Multi' do it_behaves_like 'B3 Multi distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['b3multi'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['b3multi'] } } let(:b3) { propagation } end end context 'for B3 Single' do it_behaves_like 'B3 Single distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['b3'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['b3'] } } let(:b3_single) { propagation } end end context 'for Datadog' do it_behaves_like 'Datadog distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['datadog'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['datadog'] } } let(:datadog) { propagation } end end context 'for Trace Context' do it_behaves_like 'Trace Context distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['tracecontext'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['tracecontext'] } } let(:datadog) { propagation } end end context 'for None' do it_behaves_like 'None distributed format' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_style = ['none'] } } + before { Datadog.configure { |c| c.tracing.propagation_style = ['none'] } } let(:datadog) { propagation } end end diff --git a/spec/datadog/tracing/distributed/propagation_spec.rb b/spec/datadog/tracing/distributed/propagation_spec.rb index d726ef942f0..94e6642ba5f 100644 --- a/spec/datadog/tracing/distributed/propagation_spec.rb +++ b/spec/datadog/tracing/distributed/propagation_spec.rb @@ -97,7 +97,7 @@ context 'with no styles configured' do before do Datadog.configure do |c| - c.tracing.distributed_tracing.propagation_inject_style = [] + c.tracing.propagation_style_inject = [] end end @@ -315,7 +315,7 @@ end context 'with propagation_extract_first true' do - before { Datadog.configure { |c| c.tracing.distributed_tracing.propagation_extract_first = true } } + before { Datadog.configure { |c| c.tracing.propagation_extract_first = true } } it 'does not preserve tracestate' do expect(trace_digest.trace_state).to be nil diff --git a/spec/datadog/tracing/tracer_integration_spec.rb b/spec/datadog/tracing/tracer_integration_spec.rb index 188bf955f6c..119cb598c80 100644 --- a/spec/datadog/tracing/tracer_integration_spec.rb +++ b/spec/datadog/tracing/tracer_integration_spec.rb @@ -355,8 +355,8 @@ def lang_tag(span) context 'with distributed Trace Context headers' do before do Datadog.configure do |c| - c.tracing.distributed_tracing.propagation_extract_style = ['tracecontext'] - c.tracing.distributed_tracing.propagation_inject_style = ['tracecontext'] + c.tracing.propagation_style_extract = ['tracecontext'] + c.tracing.propagation_style_inject = ['tracecontext'] end end