diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 860b0641aa9..8e02c1800e4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,8 +11,6 @@ /lib/datadog/tracing.rb @DataDog/tracing-ruby /lib/datadog/opentelemetry/ @DataDog/tracing-ruby /lib/datadog/opentelemetry.rb @DataDog/tracing-ruby -/lib/datadog/opentracer/ @DataDog/tracing-ruby -/lib/datadog/opentracer.rb @DataDog/tracing-ruby /lib-injection/ @DataDog/tracing-ruby /lib/datadog/profiling/ @DataDog/profiling-rb /lib/datadog/profiling.rb @DataDog/profiling-rb @@ -25,8 +23,6 @@ /sig/datadog/tracing.rbs @DataDog/tracing-ruby /sig/datadog/opentelemetry/ @DataDog/tracing-ruby /sig/datadog/opentelemetry.rbs @DataDog/tracing-ruby -/sig/datadog/opentracer/ @DataDog/tracing-ruby -/sig/datadog/opentracer.rbs @DataDog/tracing-ruby /sig/datadog/profiling/ @DataDog/profiling-rb /sig/datadog/profiling.rbs @DataDog/profiling-rb @@ -36,7 +32,5 @@ /spec/datadog/tracing_spec.rb @DataDog/tracing-ruby /spec/datadog/opentelemetry/ @DataDog/tracing-ruby /spec/datadog/opentelemetry_spec.rb @DataDog/tracing-ruby -/spec/datadog/opentracer/ @DataDog/tracing-ruby -/spec/datadog/opentracer.rb @DataDog/tracing-ruby /spec/datadog/profiling/ @DataDog/profiling-rb /spec/datadog/profiling_spec.rb @DataDog/profiling-rb diff --git a/.github/workflows/test-head.yaml b/.github/workflows/test-head.yaml index 2db13ae701b..f933e5ab5cc 100644 --- a/.github/workflows/test-head.yaml +++ b/.github/workflows/test-head.yaml @@ -27,8 +27,6 @@ jobs: continue-on-error: true - run: bundle exec rake spec:contrib continue-on-error: true - - run: bundle exec rake spec:opentracer - continue-on-error: true # A few contrib jobs that `ddtrace` already includes their gem in the global Gemfile. # We technically don't need appraisal to run them, thus are easy candidates for early testing. - run: bundle exec rake spec:rake diff --git a/.rubocop.yml b/.rubocop.yml index 0566b3358d9..b3e744063f9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -457,7 +457,6 @@ Naming/FileName: - CRuby - GC - OpenTelemetry - - OpenTracer - VM - SDK - GraphQL diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 55fcb5ca411..5cc84ab623b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -23,9 +23,6 @@ Lint/MissingCopEnableDirective: Lint/MissingSuper: Exclude: - 'lib/datadog/core/workers/runtime_metrics.rb' - - 'lib/datadog/opentracer/scope.rb' - - 'lib/datadog/opentracer/span.rb' - - 'lib/datadog/opentracer/span_context.rb' - 'lib/datadog/profiling/scheduler.rb' - 'spec/support/faux_transport.rb' - 'spec/support/spy_transport.rb' @@ -67,12 +64,6 @@ Naming/FileName: - 'lib/ddtrace/transport/ext.rb' - 'lib/ddtrace/version.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/EmptyExampleGroup: - Exclude: - - 'spec/datadog/opentracer/distributed_headers_spec.rb' - # Offense count: 1 RSpec/IteratedExpectation: Exclude: @@ -107,15 +98,12 @@ RSpec/RepeatedDescription: # Offense count: 10 RSpec/RepeatedExampleGroupDescription: Exclude: - - 'spec/datadog/opentracer/scope_manager_spec.rb' - - 'spec/datadog/opentracer/thread_local_scope_manager_spec.rb' - 'spec/datadog/tracing/contrib/grape/tracer_spec.rb' - 'spec/datadog/tracing/contrib/redis/quantize_spec.rb' # Offense count: 40 RSpec/ScatteredSetup: Exclude: - - 'spec/datadog/opentracer/span_spec.rb' - 'spec/datadog/tracing/benchmark/support/benchmark_helper.rb' - 'spec/datadog/tracing/contrib/action_cable/instrumentation_spec.rb' - 'spec/datadog/tracing/contrib/action_cable/patcher_spec.rb' diff --git a/Rakefile b/Rakefile index c06e620b8f5..ffd733f0882 100644 --- a/Rakefile +++ b/Rakefile @@ -26,9 +26,6 @@ TEST_METADATA = { 'contrib' => { '' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby' }, - 'opentracer' => { - 'opentracing' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby' - }, 'opentelemetry' => { 'opentelemetry' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ❌ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ❌ jruby' }, @@ -336,7 +333,7 @@ namespace :spec do desc '' # "Explicitly hiding from `rake -T`" RSpec::Core::RakeTask.new(:main) do |t, args| t.pattern = 'spec/**/*_spec.rb' - t.exclude_pattern = 'spec/**/{contrib,benchmark,redis,opentracer,auto_instrument,opentelemetry,profiling}/**/*_spec.rb,'\ + t.exclude_pattern = 'spec/**/{contrib,benchmark,redis,auto_instrument,opentelemetry,profiling}/**/*_spec.rb,'\ ' spec/**/{auto_instrument,opentelemetry}_spec.rb' t.rspec_opts = args.to_a.join(' ') end @@ -346,12 +343,6 @@ namespace :spec do t.rspec_opts = args.to_a.join(' ') end - desc '' # "Explicitly hiding from `rake -T`" - RSpec::Core::RakeTask.new(:opentracer) do |t, args| - t.pattern = 'spec/datadog/opentracer/**/*_spec.rb' - t.rspec_opts = args.to_a.join(' ') - end - desc '' # "Explicitly hiding from `rake -T`" RSpec::Core::RakeTask.new(:opentelemetry) do |t, args| t.pattern = 'spec/datadog/opentelemetry/**/*_spec.rb,spec/datadog/opentelemetry_spec.rb' diff --git a/Steepfile b/Steepfile index b6fa61aab06..bf60b345809 100644 --- a/Steepfile +++ b/Steepfile @@ -151,22 +151,6 @@ target :ddtrace do ignore 'lib/datadog/opentelemetry/sdk/propagator.rb' ignore 'lib/datadog/opentelemetry/sdk/span_processor.rb' ignore 'lib/datadog/opentelemetry/sdk/trace/span.rb' - ignore 'lib/datadog/opentracer.rb' - ignore 'lib/datadog/opentracer/binary_propagator.rb' - ignore 'lib/datadog/opentracer/carrier.rb' - ignore 'lib/datadog/opentracer/distributed_headers.rb' - ignore 'lib/datadog/opentracer/global_tracer.rb' - ignore 'lib/datadog/opentracer/propagator.rb' - ignore 'lib/datadog/opentracer/rack_propagator.rb' - ignore 'lib/datadog/opentracer/scope.rb' - ignore 'lib/datadog/opentracer/scope_manager.rb' - ignore 'lib/datadog/opentracer/span.rb' - ignore 'lib/datadog/opentracer/span_context.rb' - ignore 'lib/datadog/opentracer/span_context_factory.rb' - ignore 'lib/datadog/opentracer/text_map_propagator.rb' - ignore 'lib/datadog/opentracer/thread_local_scope.rb' - ignore 'lib/datadog/opentracer/thread_local_scope_manager.rb' - ignore 'lib/datadog/opentracer/tracer.rb' ignore 'lib/datadog/profiling/collectors/code_provenance.rb' ignore 'lib/datadog/profiling/ext/forking.rb' ignore 'lib/datadog/profiling/scheduler.rb' @@ -623,7 +607,6 @@ target :ddtrace do library 'minitest' library 'mysql2' library 'mysql2-aurora' - library 'opentracing' library 'concurrent-ruby' library 'faraday' library 'seahorse' diff --git a/docs/Compatibility.md b/docs/Compatibility.md index 857d2105209..fb61bbe6504 100644 --- a/docs/Compatibility.md +++ b/docs/Compatibility.md @@ -35,7 +35,7 @@ The Ruby Datadog Trace library is open source. See the [dd-trace-rb][1] GitHub r | Type | Documentation | Version | Gem version support | | ----------- | ----------------------------------------------- | --------------------- | ------------------- | -| OpenTracing | https://github.com/opentracing/opentracing-ruby | 0.4.1+ | >= 0.16.0 | +| OpenTracing | https://github.com/opentracing/opentracing-ruby | 0.4.1+ | < 2.0.0 | *Full* support indicates all tracer features are available. diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 34506555084..5b8c6d240d0 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -143,44 +143,6 @@ If your application does not use the supported gems (Rails or Hanami) above, you - [Add additional configuration settings](#additional-configuration) - [Activate or reconfigure instrumentation](#integration-instrumentation) -#### Configuring OpenTracing - -1. Add the `ddtrace` gem to your Gemfile: - - ```ruby - source 'https://rubygems.org' - gem 'ddtrace' - ``` - -2. Install the gem with `bundle install` -3. To your OpenTracing configuration file, add the following: - - ```ruby - require 'opentracing' - require 'datadog/tracing' - require 'datadog/opentracer' - - # Activate the Datadog tracer for OpenTracing - OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new - ``` - -4. Add a configuration block to your application: - - ```ruby - Datadog.configure do |c| - # Configure the Datadog tracer here. - # Activate integrations, change tracer settings, etc... - # By default without additional configuration, - # no additional integrations will be traced, only - # what you have instrumented with OpenTracing. - end - ``` - - Using this block you can: - - - [Add additional Datadog configuration settings](#additional-configuration) - - [Activate or reconfigure Datadog instrumentation](#integration-instrumentation) - #### Configuring OpenTelemetry You can send OpenTelemetry traces directly to the Datadog Agent (without `ddtrace`) by using OTLP. Check out our documentation on [OTLP ingest in the Datadog Agent](https://docs.datadoghq.com/tracing/setup_overview/open_standards/#otlp-ingest-in-datadog-agent) for details. @@ -2620,35 +2582,6 @@ In addition, all metrics include the following tags: | `language` | Programming language traced. (e.g. `ruby`) | | `service` | List of services this associated with this metric. | -### OpenTracing - -For setting up Datadog with OpenTracing, see our [Configuring OpenTracing](#configuring-opentracing) section for details. - -**Configuring Datadog tracer settings** - -The underlying Datadog tracer can be configured by passing options (which match `Datadog::Tracer`) when configuring the global tracer: - -```ruby -# Where `options` is a Hash of options provided to Datadog::Tracer -OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new(**options) -``` - -It can also be configured by using `Datadog.configure` described in the [Additional Configuration](#additional-configuration) section. - -**Activating and configuring integrations** - -By default, configuring OpenTracing with Datadog will not automatically activate any additional instrumentation provided by Datadog. You will only receive spans and traces from OpenTracing instrumentation you have in your application. - -However, additional instrumentation provided by Datadog can be activated alongside OpenTracing using `Datadog.configure`, which can be used to enhance your tracing further. To activate this, see [Integration instrumentation](#integration-instrumentation) for more details. - -**Supported serialization formats** - -| Type | Supported? | Additional information | -| ------------------------------ | ---------- | ---------------------- | -| `OpenTracing::FORMAT_TEXT_MAP` | Yes | | -| `OpenTracing::FORMAT_RACK` | Yes | Because of the loss of resolution in the Rack format, please note that baggage items with names containing either upper case characters or `-` will be converted to lower case and `_` in a round-trip respectively. We recommend avoiding these characters or accommodating accordingly on the receiving end. | -| `OpenTracing::FORMAT_BINARY` | No | | - ### Profiling `ddtrace` can produce profiles that measure method-level application resource usage within production environments. These profiles can give insight into resources spent in Ruby code outside of existing trace instrumentation. diff --git a/lib/datadog/appsec/contrib/rails/patcher.rb b/lib/datadog/appsec/contrib/rails/patcher.rb index e4738f781be..9b88c9c8862 100644 --- a/lib/datadog/appsec/contrib/rails/patcher.rb +++ b/lib/datadog/appsec/contrib/rails/patcher.rb @@ -51,7 +51,6 @@ def before_initialize(app) BEFORE_INITIALIZE_ONLY_ONCE_PER_APP[app].run do # Middleware must be added before the application is initialized. # Otherwise the middleware stack will be frozen. - # Sometimes we don't want to activate middleware e.g. OpenTracing, etc. add_middleware(app) if Datadog.configuration.tracing[:rails][:middleware] patch_process_action end diff --git a/lib/datadog/core/telemetry/collector.rb b/lib/datadog/core/telemetry/collector.rb index a55ac5d112c..39e6cd9474f 100644 --- a/lib/datadog/core/telemetry/collector.rb +++ b/lib/datadog/core/telemetry/collector.rb @@ -155,7 +155,6 @@ def additional_payload_variables options['appsec.enabled'] = configuration.dig('appsec', 'enabled') if configuration.respond_to?('appsec') options['ci.enabled'] = configuration.dig('ci', 'enabled') if configuration.respond_to?('ci') options['tracing.opentelemetry.enabled'] = !defined?(Datadog::OpenTelemetry::LOADED).nil? - options['tracing.opentracing.enabled'] = !defined?(Datadog::OpenTracer::LOADED).nil? options.compact! options end diff --git a/lib/datadog/opentracer.rb b/lib/datadog/opentracer.rb deleted file mode 100644 index 4fb042a3767..00000000000 --- a/lib/datadog/opentracer.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require 'opentracing' -require 'opentracing/carrier' -require_relative 'tracing' - -require_relative 'opentracer/carrier' -require_relative 'opentracer/tracer' -require_relative 'opentracer/span' -require_relative 'opentracer/span_context' -require_relative 'opentracer/span_context_factory' -require_relative 'opentracer/scope' -require_relative 'opentracer/scope_manager' -require_relative 'opentracer/thread_local_scope' -require_relative 'opentracer/thread_local_scope_manager' -require_relative 'opentracer/distributed_headers' -require_relative 'opentracer/propagator' -require_relative 'opentracer/text_map_propagator' -require_relative 'opentracer/binary_propagator' -require_relative 'opentracer/rack_propagator' -require_relative 'opentracer/global_tracer' - -# Modify the OpenTracing module functions -::OpenTracing.singleton_class.prepend(Datadog::OpenTracer::GlobalTracer) - -module Datadog - # Datadog OpenTracing integration. - # DEV: This module should be named `Datadog::OpenTracing` to match the gem (`opentracing`). - module OpenTracer - # Used by Telemetry to decide if OpenTracing instrumentation is enabled - LOADED = true - end -end diff --git a/lib/datadog/opentracer/binary_propagator.rb b/lib/datadog/opentracer/binary_propagator.rb deleted file mode 100644 index fef548df6a7..00000000000 --- a/lib/datadog/opentracer/binary_propagator.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # OpenTracing propagator for Datadog::OpenTracer::Tracer - module BinaryPropagator - extend Propagator - - # Inject a SpanContext into the given carrier - # - # @param span_context [SpanContext] - # @param carrier [Carrier] A carrier object of Binary type - def self.inject(span_context, carrier) - nil - end - - # Extract a SpanContext in Binary format from the given carrier. - # - # @param carrier [Carrier] A carrier object of Binary type - # @return [SpanContext, nil] the extracted SpanContext or nil if none could be found - def self.extract(carrier) - SpanContext::NOOP_INSTANCE - end - end - end -end diff --git a/lib/datadog/opentracer/carrier.rb b/lib/datadog/opentracer/carrier.rb deleted file mode 100644 index a7798a27d08..00000000000 --- a/lib/datadog/opentracer/carrier.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # @public_api - class Carrier < ::OpenTracing::Carrier - end - end -end diff --git a/lib/datadog/opentracer/distributed_headers.rb b/lib/datadog/opentracer/distributed_headers.rb deleted file mode 100644 index 7bf7ac861b0..00000000000 --- a/lib/datadog/opentracer/distributed_headers.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tracing/distributed/datadog' -require_relative '../tracing/utils' - -module Datadog - module OpenTracer - # DistributedHeaders provides easy access and validation to headers - # @public_api - class DistributedHeaders - def initialize(carrier) - @carrier = carrier - end - - def valid? - # Sampling priority is optional. - !trace_id.nil? && !parent_id.nil? - end - - def trace_id - id Tracing::Distributed::Datadog::TRACE_ID_KEY - end - - def parent_id - id Tracing::Distributed::Datadog::PARENT_ID_KEY - end - - def sampling_priority - hdr = @carrier[Tracing::Distributed::Datadog::SAMPLING_PRIORITY_KEY] - # It's important to make a difference between no header, - # and a header defined to zero. - return unless hdr - - value = hdr.to_i - return if value < 0 - - value - end - - def origin - hdr = @carrier[Tracing::Distributed::Datadog::ORIGIN_KEY] - # Only return the value if it is not an empty string - hdr if hdr != '' - end - - private - - def id(header) - value = @carrier[header].to_i - return if value.zero? || value >= Datadog::Tracing::Utils::EXTERNAL_MAX_ID - - value < 0 ? value + 0x1_0000_0000_0000_0000 : value - end - end - end -end diff --git a/lib/datadog/opentracer/global_tracer.rb b/lib/datadog/opentracer/global_tracer.rb deleted file mode 100644 index d1b590fd5a7..00000000000 --- a/lib/datadog/opentracer/global_tracer.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # Patch for OpenTracing module - module GlobalTracer - def global_tracer=(tracer) - super.tap do - if tracer.class <= Datadog::OpenTracer::Tracer - # Update the Datadog global tracer, too. - Datadog.configure { |c| c.tracing.instance = tracer.datadog_tracer } - end - end - end - end - end -end diff --git a/lib/datadog/opentracer/propagator.rb b/lib/datadog/opentracer/propagator.rb deleted file mode 100644 index 285034e839e..00000000000 --- a/lib/datadog/opentracer/propagator.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # OpenTracing propagator for Datadog::OpenTracer::Tracer - # @abstract - # @public_api - module Propagator - # Inject a SpanContext into the given carrier - # - # @param span_context [SpanContext] - # @param carrier [Carrier] A carrier object of the type dictated by the specified `format` - def inject(span_context, carrier) - raise NotImplementedError - end - - # Extract a SpanContext in the given format from the given carrier. - # - # @param carrier [Carrier] A carrier object of the type dictated by the specified `format` - # @return [SpanContext, nil] the extracted SpanContext or nil if none could be found - def extract(carrier) - raise NotImplementedError - end - end - end -end diff --git a/lib/datadog/opentracer/rack_propagator.rb b/lib/datadog/opentracer/rack_propagator.rb deleted file mode 100644 index 9f2aba345f5..00000000000 --- a/lib/datadog/opentracer/rack_propagator.rb +++ /dev/null @@ -1,73 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tracing/context' -require_relative '../tracing/contrib/http' -require_relative '../tracing/trace_operation' -require_relative 'propagator' - -module Datadog - module OpenTracer - # OpenTracing propagator for Datadog::OpenTracer::Tracer - module RackPropagator - extend Propagator - - BAGGAGE_PREFIX = 'ot-baggage-' - BAGGAGE_PREFIX_FORMATTED = 'HTTP_OT_BAGGAGE_' - - class << self - # Inject a SpanContext into the given carrier - # - # @param span_context [SpanContext] - # @param carrier [Carrier] A carrier object of Rack type - def inject(span_context, carrier) - digest = if span_context.datadog_context && span_context.datadog_context.active_trace - span_context.datadog_context.active_trace.to_digest - else - span_context.datadog_trace_digest - end - - # Inject Datadog trace properties - Tracing::Contrib::HTTP.inject(digest, carrier) - - # Inject baggage - span_context.baggage.each do |key, value| - carrier[BAGGAGE_PREFIX + key] = value - end - - nil - end - - # Extract a SpanContext in Rack format from the given carrier. - # - # @param carrier [Carrier] A carrier object of Rack type - # @return [SpanContext, nil] the extracted SpanContext or nil if none could be found - def extract(carrier) - # First extract & build a Datadog context - datadog_trace_digest = Tracing::Contrib::HTTP.extract(carrier) - - # Then extract any other baggage - baggage = {} - carrier.each do |key, value| - baggage[header_to_baggage(key)] = value if baggage_header?(key) - end - - SpanContextFactory.build( - datadog_context: nil, - datadog_trace_digest: datadog_trace_digest, - baggage: baggage - ) - end - - private - - def baggage_header?(header) - header.to_s.start_with?(BAGGAGE_PREFIX_FORMATTED) - end - - def header_to_baggage(key) - key[BAGGAGE_PREFIX_FORMATTED.length, key.length].downcase - end - end - end - end -end diff --git a/lib/datadog/opentracer/scope.rb b/lib/datadog/opentracer/scope.rb deleted file mode 100644 index eceb38070d6..00000000000 --- a/lib/datadog/opentracer/scope.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # OpenTracing adapter for scope - # @public_api - class Scope < ::OpenTracing::Scope - attr_reader \ - :manager, - :span - - def initialize(manager:, span:) - @manager = manager - @span = span - end - end - end -end diff --git a/lib/datadog/opentracer/scope_manager.rb b/lib/datadog/opentracer/scope_manager.rb deleted file mode 100644 index a2da1cecab7..00000000000 --- a/lib/datadog/opentracer/scope_manager.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # @public_api - class ScopeManager < ::OpenTracing::ScopeManager - end - end -end diff --git a/lib/datadog/opentracer/span.rb b/lib/datadog/opentracer/span.rb deleted file mode 100644 index ccd19bea3f9..00000000000 --- a/lib/datadog/opentracer/span.rb +++ /dev/null @@ -1,101 +0,0 @@ -# frozen_string_literal: true - -require 'time' - -require_relative '../tracing/metadata/ext' - -module Datadog - module OpenTracer - # OpenTracing adapter for Datadog::Span - # @public_api - class Span < ::OpenTracing::Span - attr_reader \ - :datadog_span - - def initialize(datadog_span:, span_context:) - @datadog_span = datadog_span - @span_context = span_context - end - - # Set the name of the operation - # - # @param [String] name - def operation_name=(name) - datadog_span.name = name - end - - # Span Context - # - # @return [SpanContext] - def context - @span_context - end - - # Set a tag value on this span - # @param key [String] the key of the tag - # @param value [String, Numeric, Boolean] the value of the tag. If it's not - # a String, Numeric, or Boolean it will be encoded with to_s - def set_tag(key, value) - # Special cases to convert opentracing tags to datadog tags - case key - when 'error' - # Opentracing supports and `error: ` tag, we need to convert to span status - # DEV: Do not return, we want to still set the `error` tag as they requested - datadog_span.status = value ? Datadog::Tracing::Metadata::Ext::Errors::STATUS : 0 - end - - tap { datadog_span.set_tag(key, value) } - end - - # Set a baggage item on the span - # @param key [String] the key of the baggage item - # @param value [String] the value of the baggage item - def set_baggage_item(key, value) - tap do - # SpanContext is immutable, so to make changes - # build a new span context. - @span_context = SpanContextFactory.clone( - span_context: context, - baggage: { key => value } - ) - end - end - - # Get a baggage item - # @param key [String] the key of the baggage item - # @return [String] value of the baggage item - def get_baggage_item(key) - context.baggage[key] - end - - # @deprecated Use {#log_kv} instead. - # Reason: event is an optional standard log field defined in spec and not required. Also, - # method name {#log_kv} is more consistent with other language implementations such as Python and Go. - # - # Add a log entry to this span - # @param event [String] event name for the log - # @param timestamp [Time] time of the log - # @param fields [Hash] Additional information to log - def log(event: nil, timestamp: Time.now, **fields) - super # Log deprecation warning - - # If the fields specify an error - datadog_span.set_error(fields[:'error.object']) if fields.key?(:'error.object') - end - - # Add a log entry to this span - # @param timestamp [Time] time of the log - # @param fields [Hash] Additional information to log - def log_kv(timestamp: Time.now, **fields) - # If the fields specify an error - datadog_span.set_error(fields[:'error.object']) if fields.key?(:'error.object') - end - - # Finish the {Span} - # @param end_time [Time] custom end time, if not now - def finish(end_time: Time.now) - datadog_span.finish(end_time) - end - end - end -end diff --git a/lib/datadog/opentracer/span_context.rb b/lib/datadog/opentracer/span_context.rb deleted file mode 100644 index 96c42229f48..00000000000 --- a/lib/datadog/opentracer/span_context.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # OpenTracing adapter for SpanContext - # @public_api - class SpanContext < ::OpenTracing::SpanContext - attr_reader \ - :datadog_context, - :datadog_trace_digest - - def initialize(datadog_context:, datadog_trace_digest: nil, baggage: {}) - @datadog_context = datadog_context - @datadog_trace_digest = datadog_trace_digest - @baggage = baggage.freeze - end - end - end -end diff --git a/lib/datadog/opentracer/span_context_factory.rb b/lib/datadog/opentracer/span_context_factory.rb deleted file mode 100644 index 492361974dd..00000000000 --- a/lib/datadog/opentracer/span_context_factory.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # Creates new Datadog::OpenTracer::SpanContext - module SpanContextFactory - module_function - - def build(datadog_context:, datadog_trace_digest: nil, baggage: {}) - SpanContext.new( - datadog_context: datadog_context, - datadog_trace_digest: datadog_trace_digest, - baggage: baggage.dup - ) - end - - def clone(span_context:, baggage: {}) - SpanContext.new( - datadog_context: span_context.datadog_context, - datadog_trace_digest: span_context.datadog_trace_digest, - # Merge baggage from previous SpanContext - baggage: span_context.baggage.merge(baggage) - ) - end - end - end -end diff --git a/lib/datadog/opentracer/text_map_propagator.rb b/lib/datadog/opentracer/text_map_propagator.rb deleted file mode 100644 index 9d659c7e28f..00000000000 --- a/lib/datadog/opentracer/text_map_propagator.rb +++ /dev/null @@ -1,89 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tracing/context' -require_relative '../tracing/distributed/datadog' -require_relative '../tracing/trace_operation' -require_relative 'propagator' - -module Datadog - module OpenTracer - # OpenTracing propagator for Datadog::OpenTracer::Tracer - module TextMapPropagator - extend Propagator - - BAGGAGE_PREFIX = 'ot-baggage-' - - class << self - # Inject a SpanContext into the given carrier - # - # @param span_context [SpanContext] - # @param carrier [Carrier] A carrier object of Rack type - def inject(span_context, carrier) - # Inject baggage - span_context.baggage.each do |key, value| - carrier[BAGGAGE_PREFIX + key] = value - end - - # Inject Datadog trace properties - digest = if span_context.datadog_context && span_context.datadog_context.active_trace - span_context.datadog_context.active_trace.to_digest - else - span_context.datadog_trace_digest - end - return unless digest - - carrier[Tracing::Distributed::Datadog::ORIGIN_KEY] = digest.trace_origin - carrier[Tracing::Distributed::Datadog::PARENT_ID_KEY] = digest.span_id - carrier[Tracing::Distributed::Datadog::SAMPLING_PRIORITY_KEY] = digest.trace_sampling_priority - carrier[Tracing::Distributed::Datadog::TRACE_ID_KEY] = - Datadog::Tracing::Utils::TraceId.to_low_order(digest.trace_id) - - nil - end - - # Extract a SpanContext in TextMap format from the given carrier. - # - # @param carrier [Carrier] A carrier object of TextMap type - # @return [SpanContext, nil] the extracted SpanContext or nil if none could be found - def extract(carrier) - # First extract & build a Datadog context - headers = DistributedHeaders.new(carrier) - datadog_trace_digest = headers_to_trace_digest(headers) - - # Then extract any other baggage - baggage = {} - carrier.each do |key, value| - baggage[item_to_baggage(key)] = value if baggage_item?(key) - end - - SpanContextFactory.build( - datadog_context: nil, - datadog_trace_digest: datadog_trace_digest, - baggage: baggage - ) - end - - private - - def headers_to_trace_digest(headers) - return unless headers.valid? - - Datadog::Tracing::TraceDigest.new( - span_id: headers.parent_id, - trace_id: headers.trace_id, - trace_origin: headers.origin, - trace_sampling_priority: headers.sampling_priority - ) - end - - def baggage_item?(item) - item.to_s.start_with?(BAGGAGE_PREFIX) - end - - def item_to_baggage(key) - key[BAGGAGE_PREFIX.length, key.length] - end - end - end - end -end diff --git a/lib/datadog/opentracer/thread_local_scope.rb b/lib/datadog/opentracer/thread_local_scope.rb deleted file mode 100644 index ec842c9a5d1..00000000000 --- a/lib/datadog/opentracer/thread_local_scope.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module Datadog - module OpenTracer - # OpenTracing adapter for thread local scopes - # @public_api - class ThreadLocalScope < Scope - attr_reader \ - :finish_on_close - - def initialize( - manager:, - span:, - finish_on_close: true - ) - super(manager: manager, span: span) - @finish_on_close = finish_on_close - @previous_scope = manager.active - end - - # Mark the end of the active period for the current thread and Scope, - # updating the ScopeManager#active in the process. - # - # NOTE: Calling close more than once on a single Scope instance leads to - # undefined behavior. - def close - return unless equal?(manager.active) - - span.finish if finish_on_close - manager.send(:set_scope, @previous_scope) - end - end - end -end diff --git a/lib/datadog/opentracer/thread_local_scope_manager.rb b/lib/datadog/opentracer/thread_local_scope_manager.rb deleted file mode 100644 index dae4fd11c0e..00000000000 --- a/lib/datadog/opentracer/thread_local_scope_manager.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -require_relative '../core/utils/sequence' - -module Datadog - module OpenTracer - # OpenTracing adapter for thread local scope management - # @public_api - class ThreadLocalScopeManager < ScopeManager - def initialize(*args, &block) - super(*args, &block) - @thread_key = "dd_opentracer_context_#{ThreadLocalScopeManager.next_instance_id}".to_sym - end - - ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true) - - # Make a span instance active. - # - # @param span [Span] the Span that should become active - # @param finish_on_close [Boolean] whether the Span should automatically be - # finished when Scope#close is called - # @return [Scope] instance to control the end of the active period for the - # Span. It is a programming error to neglect to call Scope#close on the - # returned instance. - def activate(span, finish_on_close: true) - ThreadLocalScope.new( - manager: self, - span: span, - finish_on_close: finish_on_close - ).tap do |scope| - set_scope(scope) - end - end - - # @return [Scope] the currently active Scope which can be used to access the - # currently active Span. - # - # If there is a non-null Scope, its wrapped Span becomes an implicit parent - # (as Reference#CHILD_OF) of any newly-created Span at Tracer#start_active_span - # or Tracer#start_span time. - def active - Thread.current[@thread_key] - end - - # Ensure two instances of {FiberLocalContext} do not conflict. - # We previously used {FiberLocalContext#object_id} to ensure uniqueness - # but the VM is allowed to reuse `object_id`, allow for the possibility that - # a new FiberLocalContext would be able to read an old FiberLocalContext's - # value. - UNIQUE_INSTANCE_MUTEX = Mutex.new - UNIQUE_INSTANCE_GENERATOR = Datadog::Core::Utils::Sequence.new - - private_constant :UNIQUE_INSTANCE_MUTEX, :UNIQUE_INSTANCE_GENERATOR - - def self.next_instance_id - UNIQUE_INSTANCE_MUTEX.synchronize { UNIQUE_INSTANCE_GENERATOR.next } - end - - private - - def set_scope(scope) - Thread.current[@thread_key] = scope - end - end - end -end diff --git a/lib/datadog/opentracer/tracer.rb b/lib/datadog/opentracer/tracer.rb deleted file mode 100644 index 2bcfe00f9c0..00000000000 --- a/lib/datadog/opentracer/tracer.rb +++ /dev/null @@ -1,214 +0,0 @@ -# frozen_string_literal: true - -require 'time' - -require_relative '../tracing/context' -require_relative '../tracing/tracer' - -module Datadog - module OpenTracer - # OpenTracing adapter for Datadog::Tracer - # @public_api - class Tracer < ::OpenTracing::Tracer - # (see Datadog::Tracer) - # @return [Datadog::Tracer] - attr_reader \ - :datadog_tracer - - # (see Datadog::Tracer#initialize) - def initialize(**options) - super() - @datadog_tracer = Datadog::Tracing::Tracer.new(**options) - end - - # @return [ScopeManager] the current ScopeManager. - def scope_manager - @scope_manager ||= ThreadLocalScopeManager.new - end - - # Returns a newly started and activated {Scope}. - # - # If `scope_manager.active` is not nil, no explicit references - # are provided, and `ignore_active_scope` is false, then an inferred - # {https://www.rubydoc.info/gems/opentracing/0.5.0/OpenTracing/Reference OpenTracing::Reference#CHILD_OF} - # reference is created to the `scope_manager.active`'s - # {SpanContext} when {#start_active_span} is invoked. - # - # @param operation_name [String] The operation name for the Span - # @param child_of [SpanContext, Span] SpanContext that acts as a parent to - # the newly-started Span. If a Span instance is provided, its - # context is automatically substituted. See [OpenTracing::Reference] for more - # information. - # If specified, the `references` parameter must be omitted. - # @param references [Array] An array of reference - # objects that identify one or more parent SpanContexts. - # @param start_time [Time] When the Span started, if not now - # @param tags [Hash] Tags to assign to the Span at start time - # @param ignore_active_scope [Boolean] whether to create an implicit - # OpenTracing::Reference#CHILD_OF reference to the ScopeManager#active. - # @param finish_on_close [Boolean] whether span should automatically be - # finished when Scope#close is called - # @yield [Scope] If an optional block is passed to start_active it will - # yield the newly-started Scope. If `finish_on_close` is true then the - # Span will be finished automatically after the block is executed. - # @return [Scope] The newly-started and activated Scope - def start_active_span( - operation_name, - child_of: nil, - references: nil, - start_time: Time.now, - tags: nil, - ignore_active_scope: false, - finish_on_close: true - ) - - # When meant to automatically determine the parent, - # Use the active scope first, otherwise fall back to any - # context generated by Datadog, so as to append to it and gain - # the benefit of any out-of-the-box tracing from Datadog preceding - # the OpenTracer::Tracer. - # - # We do this here instead of in #start_span because #start_span generates - # spans that are not assigned to a scope, a.k.a not supposed to be used by - # subsequent spans implicitly. By using the existing Datadog context, the span - # effectively ends up "assigned to a scope", by virtue of being added to the - # Context. Hence, it would behave more like an active span, which is why it - # should only be here. - unless child_of || ignore_active_scope - child_of = if scope_manager.active - scope_manager.active.span.context - else - SpanContextFactory.build(datadog_context: datadog_tracer.send(:call_context)) - end - end - - # Create the span, and auto-add it to the Datadog context. - span = start_span( - operation_name, - child_of: child_of, - references: references, - start_time: start_time, - tags: tags, - ignore_active_scope: ignore_active_scope - ) - - # Overwrite the tracer context with the OpenTracing managed context. - # This is mostly for the benefit of any out-of-the-box tracing from Datadog, - # such that spans generated by that tracing will be attached to the OpenTracer - # parent span. - datadog_tracer.provider.context = span.context.datadog_context - - scope_manager.activate(span, finish_on_close: finish_on_close).tap do |scope| - if block_given? - begin - yield(scope) - ensure - scope.close - end - end - end - end - - # Like {#start_active_span}, but the returned {Span} has not been registered via the - # {ScopeManager}. - # - # @param operation_name [String] The operation name for the Span - # @param child_of [SpanContext, Span] SpanContext that acts as a parent to - # the newly-started Span. If a Span instance is provided, its - # context is automatically substituted. See [Reference] for more - # information. - # If specified, the `references` parameter must be omitted. - # @param references [Array] An array of reference - # objects that identify one or more parent SpanContexts. - # @param start_time [Time] When the Span started, if not now - # @param tags [Hash] Tags to assign to the Span at start time - # @param ignore_active_scope [Boolean] whether to create an implicit - # References#CHILD_OF reference to the ScopeManager#active. - # @return [Span] the newly-started Span instance, which has not been - # automatically registered via the ScopeManager - def start_span( - operation_name, - child_of: nil, - references: nil, - start_time: Time.now, - tags: nil, - ignore_active_scope: false - ) - - # Derive the OpenTracer::SpanContext to inherit from. - parent_span_context = inherited_span_context(child_of, ignore_active_scope: ignore_active_scope) - - # Retrieve Datadog::Context from parent SpanContext. - datadog_context = parent_span_context.nil? ? Datadog::Tracing::Context.new : parent_span_context.datadog_context - datadog_trace_digest = parent_span_context && parent_span_context.datadog_trace_digest - - # Build the new Datadog span - datadog_span = datadog_tracer.trace( - operation_name, - continue_from: datadog_trace_digest, - _context: datadog_context, - start_time: start_time, - tags: tags || {} - ) - - span_context = SpanContextFactory.build( - datadog_context: datadog_context || datadog_tracer.send(:call_context), - baggage: parent_span_context ? parent_span_context.baggage.dup : {} - ) - - # Wrap the Datadog span and OpenTracer::Span context in a OpenTracer::Span - Span.new(datadog_span: datadog_span, span_context: span_context) - end - - # Inject a {SpanContext} into the given carrier. - # - # @param span_context [SpanContext] - # @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK] - # @param carrier [Carrier] A carrier object of the type dictated by the specified `format` - def inject(span_context, format, carrier) - case format - when OpenTracing::FORMAT_TEXT_MAP - TextMapPropagator.inject(span_context, carrier) - when OpenTracing::FORMAT_BINARY - BinaryPropagator.inject(span_context, carrier) - when OpenTracing::FORMAT_RACK - RackPropagator.inject(span_context, carrier) - else - warn 'Unknown inject format' - end - end - - # Extract a {SpanContext} in the given format from the given carrier. - # - # @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK] - # @param carrier [Carrier] A carrier object of the type dictated by the specified `format` - # @return [SpanContext, nil] the extracted SpanContext or nil if none could be found - def extract(format, carrier) - case format - when OpenTracing::FORMAT_TEXT_MAP - TextMapPropagator.extract(carrier) - when OpenTracing::FORMAT_BINARY - BinaryPropagator.extract(carrier) - when OpenTracing::FORMAT_RACK - RackPropagator.extract(carrier) - else - warn 'Unknown extract format' - nil - end - end - - private - - def inherited_span_context(parent, ignore_active_scope: false) - case parent - when Span - parent.context - when SpanContext - parent - else - ignore_active_scope ? nil : scope_manager.active && scope_manager.active.span.context - end - end - end - end -end diff --git a/lib/datadog/tracing/contrib/rails/patcher.rb b/lib/datadog/tracing/contrib/rails/patcher.rb index 6c49e5d858b..b2309e939e1 100644 --- a/lib/datadog/tracing/contrib/rails/patcher.rb +++ b/lib/datadog/tracing/contrib/rails/patcher.rb @@ -53,7 +53,6 @@ def before_initialize(app) BEFORE_INITIALIZE_ONLY_ONCE_PER_APP[app].run do # Middleware must be added before the application is initialized. # Otherwise the middleware stack will be frozen. - # Sometimes we don't want to activate middleware e.g. OpenTracing, etc. add_middleware(app) if Datadog.configuration.tracing[:rails][:middleware] # ActionDispatch::Journey is not available or incompatible in Rails < 4.2. diff --git a/sig/datadog/opentracer.rbs b/sig/datadog/opentracer.rbs deleted file mode 100644 index cf6e2c56bc2..00000000000 --- a/sig/datadog/opentracer.rbs +++ /dev/null @@ -1 +0,0 @@ -# This file intentionally empty: nothing to type diff --git a/sig/datadog/opentracer/binary_propagator.rbs b/sig/datadog/opentracer/binary_propagator.rbs deleted file mode 100644 index ce47665eb9b..00000000000 --- a/sig/datadog/opentracer/binary_propagator.rbs +++ /dev/null @@ -1,9 +0,0 @@ -module Datadog - module OpenTracer - module BinaryPropagator - extend Propagator - def self.inject: (untyped span_context, untyped carrier) -> nil - def self.extract: (untyped carrier) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/carrier.rbs b/sig/datadog/opentracer/carrier.rbs deleted file mode 100644 index 9bd95c43843..00000000000 --- a/sig/datadog/opentracer/carrier.rbs +++ /dev/null @@ -1,6 +0,0 @@ -module Datadog - module OpenTracer - class Carrier < ::OpenTracing::Carrier - end - end -end diff --git a/sig/datadog/opentracer/distributed_headers.rbs b/sig/datadog/opentracer/distributed_headers.rbs deleted file mode 100644 index 917e65966e0..00000000000 --- a/sig/datadog/opentracer/distributed_headers.rbs +++ /dev/null @@ -1,21 +0,0 @@ -module Datadog - module OpenTracer - class DistributedHeaders - def initialize: (untyped carrier) -> void - - def valid?: () -> untyped - - def trace_id: () -> untyped - - def parent_id: () -> untyped - - def sampling_priority: () -> (nil | untyped) - - def origin: () -> untyped - - private - - def id: (untyped header) -> (nil | untyped) - end - end -end diff --git a/sig/datadog/opentracer/global_tracer.rbs b/sig/datadog/opentracer/global_tracer.rbs deleted file mode 100644 index 4a49a24a795..00000000000 --- a/sig/datadog/opentracer/global_tracer.rbs +++ /dev/null @@ -1,7 +0,0 @@ -module Datadog - module OpenTracer - module GlobalTracer - def global_tracer=: (untyped tracer) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/propagator.rbs b/sig/datadog/opentracer/propagator.rbs deleted file mode 100644 index ff94de081ac..00000000000 --- a/sig/datadog/opentracer/propagator.rbs +++ /dev/null @@ -1,8 +0,0 @@ -module Datadog - module OpenTracer - module Propagator - def inject: (untyped span_context, untyped carrier) -> untyped - def extract: (untyped carrier) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/rack_propagator.rbs b/sig/datadog/opentracer/rack_propagator.rbs deleted file mode 100644 index f424834e0bd..00000000000 --- a/sig/datadog/opentracer/rack_propagator.rbs +++ /dev/null @@ -1,19 +0,0 @@ -module Datadog - module OpenTracer - module RackPropagator - extend Propagator - - BAGGAGE_PREFIX: "ot-baggage-" - - BAGGAGE_PREFIX_FORMATTED: "HTTP_OT_BAGGAGE_" - def self.inject: (untyped span_context, untyped carrier) -> nil - def self.extract: (untyped carrier) -> untyped - - private - - def self.baggage_header?: (untyped header) -> untyped - - def self.header_to_baggage: (untyped key) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/scope.rbs b/sig/datadog/opentracer/scope.rbs deleted file mode 100644 index a9cc938c4f0..00000000000 --- a/sig/datadog/opentracer/scope.rbs +++ /dev/null @@ -1,11 +0,0 @@ -module Datadog - module OpenTracer - class Scope < ::OpenTracing::Scope - attr_reader manager: untyped - - attr_reader span: untyped - - def initialize: (manager: untyped, span: untyped) -> void - end - end -end diff --git a/sig/datadog/opentracer/scope_manager.rbs b/sig/datadog/opentracer/scope_manager.rbs deleted file mode 100644 index 887a40cbd62..00000000000 --- a/sig/datadog/opentracer/scope_manager.rbs +++ /dev/null @@ -1,6 +0,0 @@ -module Datadog - module OpenTracer - class ScopeManager < ::OpenTracing::ScopeManager - end - end -end diff --git a/sig/datadog/opentracer/span.rbs b/sig/datadog/opentracer/span.rbs deleted file mode 100644 index d011ad0c446..00000000000 --- a/sig/datadog/opentracer/span.rbs +++ /dev/null @@ -1,17 +0,0 @@ -module Datadog - module OpenTracer - class Span < ::OpenTracing::Span - attr_reader datadog_span: untyped - - def initialize: (datadog_span: untyped, span_context: untyped) -> void - def operation_name=: (untyped name) -> untyped - def context: () -> untyped - def set_tag: (untyped key, untyped value) -> untyped - def set_baggage_item: (untyped key, untyped value) -> untyped - def get_baggage_item: (untyped key) -> untyped - def log: (?event: untyped?, ?timestamp: untyped, **untyped fields) -> untyped - def log_kv: (?timestamp: untyped, **untyped fields) -> (untyped | nil) - def finish: (?end_time: untyped) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/span_context.rbs b/sig/datadog/opentracer/span_context.rbs deleted file mode 100644 index 126ab94b5c8..00000000000 --- a/sig/datadog/opentracer/span_context.rbs +++ /dev/null @@ -1,11 +0,0 @@ -module Datadog - module OpenTracer - class SpanContext < ::OpenTracing::SpanContext - attr_reader datadog_context: untyped - - attr_reader datadog_trace_digest: untyped - - def initialize: (datadog_context: untyped, ?datadog_trace_digest: untyped?, ?baggage: ::Hash[untyped, untyped]) -> void - end - end -end diff --git a/sig/datadog/opentracer/span_context_factory.rbs b/sig/datadog/opentracer/span_context_factory.rbs deleted file mode 100644 index b7ab9dbfe0a..00000000000 --- a/sig/datadog/opentracer/span_context_factory.rbs +++ /dev/null @@ -1,9 +0,0 @@ -module Datadog - module OpenTracer - module SpanContextFactory - def self?.build: (datadog_context: untyped, ?datadog_trace_digest: untyped?, ?baggage: ::Hash[untyped, untyped]) -> untyped - - def self?.clone: (span_context: untyped, ?baggage: ::Hash[untyped, untyped]) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/text_map_propagator.rbs b/sig/datadog/opentracer/text_map_propagator.rbs deleted file mode 100644 index f3d044a79f9..00000000000 --- a/sig/datadog/opentracer/text_map_propagator.rbs +++ /dev/null @@ -1,19 +0,0 @@ -module Datadog - module OpenTracer - module TextMapPropagator - extend Propagator - - BAGGAGE_PREFIX: "ot-baggage-" - def self.inject: (untyped span_context, untyped carrier) -> nil - def self.extract: (untyped carrier) -> untyped - - private - - def self.headers_to_trace_digest: (untyped headers) -> (nil | untyped) - - def self.baggage_item?: (untyped item) -> untyped - - def self.item_to_baggage: (untyped key) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/thread_local_scope.rbs b/sig/datadog/opentracer/thread_local_scope.rbs deleted file mode 100644 index c92f0c40cf6..00000000000 --- a/sig/datadog/opentracer/thread_local_scope.rbs +++ /dev/null @@ -1,10 +0,0 @@ -module Datadog - module OpenTracer - class ThreadLocalScope < Scope - attr_reader finish_on_close: untyped - - def initialize: (manager: untyped, span: untyped, ?finish_on_close: bool) -> void - def close: () -> (nil | untyped) - end - end -end diff --git a/sig/datadog/opentracer/thread_local_scope_manager.rbs b/sig/datadog/opentracer/thread_local_scope_manager.rbs deleted file mode 100644 index 67f01515276..00000000000 --- a/sig/datadog/opentracer/thread_local_scope_manager.rbs +++ /dev/null @@ -1,18 +0,0 @@ -module Datadog - module OpenTracer - class ThreadLocalScopeManager < ScopeManager - def initialize: (*untyped args) ?{ () -> untyped } -> void - def activate: (untyped span, ?finish_on_close: bool) -> untyped - def active: () -> untyped - UNIQUE_INSTANCE_MUTEX: untyped - - UNIQUE_INSTANCE_GENERATOR: untyped - - def self.next_instance_id: () -> untyped - - private - - def set_scope: (untyped scope) -> untyped - end - end -end diff --git a/sig/datadog/opentracer/tracer.rbs b/sig/datadog/opentracer/tracer.rbs deleted file mode 100644 index c64733b8431..00000000000 --- a/sig/datadog/opentracer/tracer.rbs +++ /dev/null @@ -1,17 +0,0 @@ -module Datadog - module OpenTracer - class Tracer < ::OpenTracing::Tracer - attr_reader datadog_tracer: untyped - def initialize: (**untyped options) -> void - def scope_manager: () -> untyped - def start_active_span: (untyped operation_name, ?child_of: untyped?, ?references: untyped?, ?start_time: untyped, ?tags: untyped?, ?ignore_active_scope: bool, ?finish_on_close: bool) { (untyped) -> untyped } -> untyped - def start_span: (untyped operation_name, ?child_of: untyped?, ?references: untyped?, ?start_time: untyped, ?tags: untyped?, ?ignore_active_scope: bool) -> untyped - def inject: (untyped span_context, untyped format, untyped carrier) -> untyped - def extract: (untyped format, untyped carrier) -> untyped - - private - - def inherited_span_context: (untyped parent, ?ignore_active_scope: bool) -> untyped - end - end -end diff --git a/spec/datadog/core/telemetry/collector_spec.rb b/spec/datadog/core/telemetry/collector_spec.rb index df5c488ce3c..7faccef5810 100644 --- a/spec/datadog/core/telemetry/collector_spec.rb +++ b/spec/datadog/core/telemetry/collector_spec.rb @@ -335,14 +335,6 @@ class << Datadog.configuration it { is_expected.to include('tracing.opentelemetry.enabled' => true) } end - - context 'when OpenTracing is enabled' do - before do - stub_const('Datadog::OpenTracer::LOADED', true) - end - - it { is_expected.to include('tracing.opentracing.enabled' => true) } - end end describe '#dependencies' do diff --git a/spec/datadog/opentracer/binary_propagator_spec.rb b/spec/datadog/opentracer/binary_propagator_spec.rb deleted file mode 100644 index 8ba7bb79e86..00000000000 --- a/spec/datadog/opentracer/binary_propagator_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::BinaryPropagator do - describe '#inject' do - subject { described_class.inject(span_context, carrier) } - - let(:span_context) { instance_double(Datadog::OpenTracer::SpanContext) } - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - - it { is_expected.to be nil } - end - - describe '#extract' do - subject(:span_context) { described_class.extract(carrier) } - - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - - it { is_expected.to be(Datadog::OpenTracer::SpanContext::NOOP_INSTANCE) } - end -end diff --git a/spec/datadog/opentracer/carrier_spec.rb b/spec/datadog/opentracer/carrier_spec.rb deleted file mode 100644 index e7ea4a7ee72..00000000000 --- a/spec/datadog/opentracer/carrier_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::Carrier do - subject(:carrier) { described_class.new } - - describe '#[]' do - subject(:span) { carrier[key] } - - let(:key) { 'key' } - - it { is_expected.to be nil } - end - - describe '#[]=' do - subject(:result) { carrier[key] = value } - - let(:key) { 'key' } - let(:value) { 'value' } - - it { is_expected.to eq(value) } - end - - describe '#each' do - subject(:result) { carrier.each(&block) } - - let(:block) { proc { |key, value| } } - - it { is_expected.to be nil } - end -end diff --git a/spec/datadog/opentracer/distributed_headers_spec.rb b/spec/datadog/opentracer/distributed_headers_spec.rb deleted file mode 100644 index 3967a09564b..00000000000 --- a/spec/datadog/opentracer/distributed_headers_spec.rb +++ /dev/null @@ -1,143 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing/utils' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::DistributedHeaders do - subject(:headers) { described_class.new(carrier) } - - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - - describe '#valid?' do - subject(:valid) { headers.valid? } - - before do - allow(carrier).to receive(:[]) - .with('x-datadog-trace-id') - .and_return(trace_id) - - allow(carrier).to receive(:[]) - .with('x-datadog-parent-id') - .and_return(parent_id) - end - - context 'when #trace_id is missing' do - let(:trace_id) { nil } - let(:parent_id) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID + 1).to_s } - - it { is_expected.to be false } - end - - context 'when #parent_id is missing' do - let(:trace_id) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID + 1).to_s } - let(:parent_id) { nil } - - it { is_expected.to be false } - end - - context 'when both #trace_id and #parent_id are present' do - let(:trace_id) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 1).to_s } - let(:parent_id) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 1).to_s } - - it { is_expected.to be true } - end - end - - describe '#trace_id' do - subject(:trace_id) { headers.trace_id } - - before do - allow(carrier).to receive(:[]) - .with('x-datadog-trace-id') - .and_return(value) - end - - context 'when the header is missing' do - let(:value) { nil } - end - - context 'when the header is present' do - context 'but the value is out of range' do - let(:value) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID + 1).to_s } - - it { is_expected.to be nil } - end - - context 'and the value is in range' do - let(:value) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 1).to_s } - - it { is_expected.to eq value.to_i } - - context 'as a negative signed integer' do - # Convert signed int to unsigned int. - let(:value) { -8809075535603237910.to_s } - - it { is_expected.to eq 9637668538106313706 } - end - end - end - end - - describe '#parent_id' do - subject(:trace_id) { headers.parent_id } - - before do - allow(carrier).to receive(:[]) - .with('x-datadog-parent-id') - .and_return(value) - end - - context 'when the header is missing' do - let(:value) { nil } - end - - context 'when the header is present' do - context 'but the value is out of range' do - let(:value) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID + 1).to_s } - - it { is_expected.to be nil } - end - - context 'and the value is in range' do - let(:value) { (Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 1).to_s } - - it { is_expected.to eq value.to_i } - - context 'as a negative signed integer' do - # Convert signed int to unsigned int. - let(:value) { -8809075535603237910.to_s } - - it { is_expected.to eq 9637668538106313706 } - end - end - end - end - - describe '#sampling_priority' do - subject(:trace_id) { headers.sampling_priority } - - before do - allow(carrier).to receive(:[]) - .with('x-datadog-sampling-priority') - .and_return(value) - end - - context 'when the header is missing' do - let(:value) { nil } - end - - context 'when the header is present' do - context 'but the value is out of range' do - let(:value) { '-1' } - - it { is_expected.to be nil } - end - - context 'and the value is in range' do - let(:value) { '1' } - - it { is_expected.to eq value.to_i } - end - end - end -end diff --git a/spec/datadog/opentracer/global_tracer_spec.rb b/spec/datadog/opentracer/global_tracer_spec.rb deleted file mode 100644 index 203b3144266..00000000000 --- a/spec/datadog/opentracer/global_tracer_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing' -require 'datadog/tracing/tracer' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::GlobalTracer do - context 'when included into OpenTracing' do - describe '#global_tracer=' do - subject(:global_tracer) { OpenTracing.global_tracer = tracer } - - after { Datadog.configuration.tracing.instance = Datadog::Tracing::Tracer.new } - - context 'when given a Datadog::OpenTracer::Tracer' do - let(:tracer) { Datadog::OpenTracer::Tracer.new } - - it do - expect(global_tracer).to be(tracer) - expect(Datadog::Tracing.send(:tracer)).to be(tracer.datadog_tracer) - end - end - - context 'when given some unknown kind of tracer' do - let(:tracer) { double('other tracer') } - - it do - expect(global_tracer).to be(tracer) - expect(Datadog::Tracing.send(:tracer)).to_not be(tracer) - end - end - end - end -end diff --git a/spec/datadog/opentracer/propagation_integration_spec.rb b/spec/datadog/opentracer/propagation_integration_spec.rb deleted file mode 100644 index 3f1f65a6cc5..00000000000 --- a/spec/datadog/opentracer/propagation_integration_spec.rb +++ /dev/null @@ -1,407 +0,0 @@ -require 'spec_helper' -require 'support/rack_support' - -require 'datadog/tracing/utils' -require 'datadog/opentracer' - -RSpec.describe 'OpenTracer context propagation' do - subject(:tracer) { Datadog::OpenTracer::Tracer.new(writer: FauxWriter.new) } - - let(:datadog_tracer) { tracer.datadog_tracer } - let(:datadog_traces) { datadog_tracer.writer.traces(:keep) } - let(:datadog_spans) { datadog_tracer.writer.spans(:keep) } - - before { Datadog.configure {} } - - after do - # Ensure tracer is shutdown between test, as to not leak threads. - datadog_tracer.shutdown! - end - - describe 'via OpenTracing::FORMAT_TEXT_MAP' do - def baggage_to_carrier_format(baggage) - baggage.map { |k, v| [Datadog::OpenTracer::TextMapPropagator::BAGGAGE_PREFIX + k, v] }.to_h - end - - context 'when sending' do - let(:span_name) { 'operation.sender' } - let(:baggage) { { 'account_name' => 'acme' } } - let(:carrier) { {} } - - before do - tracer.start_active_span(span_name) do |scope| - scope.span.context.datadog_context.active_trace.sampling_priority = 1 - scope.span.context.datadog_context.active_trace.origin = 'synthetics' - baggage.each { |k, v| scope.span.set_baggage_item(k, v) } - tracer.inject( - scope.span.context, - OpenTracing::FORMAT_TEXT_MAP, - carrier - ) - end - end - - it do - expect(carrier).to include( - 'x-datadog-trace-id' => a_kind_of(Integer), - 'x-datadog-parent-id' => a_kind_of(Integer), - 'x-datadog-sampling-priority' => a_kind_of(Integer), - 'x-datadog-origin' => a_kind_of(String) - ) - - expect(carrier['x-datadog-parent-id']).to be > 0 - - baggage.each do |k, v| - expect(carrier).to include(Datadog::OpenTracer::TextMapPropagator::BAGGAGE_PREFIX + k => v) - end - end - end - - context 'when receiving' do - let(:span_name) { 'operation.receiver' } - let(:baggage) { { 'account_name' => 'acme' } } - let(:baggage_with_prefix) { baggage_to_carrier_format(baggage) } - let(:carrier) { baggage_with_prefix } - - before do - span_context = tracer.extract(OpenTracing::FORMAT_TEXT_MAP, carrier) - tracer.start_active_span(span_name, child_of: span_context) do |scope| - @scope = scope - # Do some work. - end - end - - context 'a carrier with valid headers' do - let(:carrier) do - super().merge( - 'x-datadog-trace-id' => trace_id.to_s, - 'x-datadog-parent-id' => parent_id.to_s, - 'x-datadog-sampling-priority' => sampling_priority.to_s, - 'x-datadog-origin' => origin.to_s - ) - end - - let(:trace_id) { Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 1 } - let(:parent_id) { Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 2 } - let(:sampling_priority) { 2 } - let(:origin) { 'synthetics' } - - let(:datadog_trace) { datadog_traces.first } - let(:datadog_span) { datadog_spans.first } - - it { expect(datadog_trace.sampling_priority).to eq(sampling_priority) } - it { expect(datadog_trace.origin).to eq(origin) } - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - it { expect(datadog_span.trace_id).to eq(trace_id) } - it { expect(datadog_span.parent_id).to eq(parent_id) } - it { expect(@scope.span.context.baggage).to include(baggage) } - end - - context 'a carrier with no headers' do - let(:carrier) { {} } - - let(:datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - it { expect(datadog_span.parent_id).to eq(0) } - end - end - - context 'in a round-trip' do - let(:origin_span_name) { 'operation.origin' } - let(:origin_datadog_trace) { datadog_traces.find { |x| x.name == origin_span_name } } - let(:origin_datadog_span) { datadog_spans.find { |x| x.name == origin_span_name } } - - let(:intermediate_span_name) { 'operation.intermediate' } - let(:intermediate_datadog_trace) { datadog_traces.find { |x| x.name == intermediate_span_name } } - let(:intermediate_datadog_span) { datadog_spans.find { |x| x.name == intermediate_span_name } } - - let(:destination_span_name) { 'operation.destination' } - let(:destination_datadog_trace) { datadog_traces.find { |x| x.name == destination_span_name } } - let(:destination_datadog_span) { datadog_spans.find { |x| x.name == destination_span_name } } - - let(:baggage) { { 'account_name' => 'acme' } } - - before do - tracer.start_active_span(origin_span_name) do |origin_scope| - origin_datadog_context = origin_scope.span.context.datadog_context - origin_datadog_context.active_trace.sampling_priority = 1 - origin_datadog_context.active_trace.origin = 'synthetics' - baggage.each { |k, v| origin_scope.span.set_baggage_item(k, v) } - - @origin_carrier = {}.tap do |c| - tracer.inject(origin_scope.span.context, OpenTracing::FORMAT_TEXT_MAP, c) - end - origin_datadog_context.activate!(nil) do - tracer.start_active_span( - intermediate_span_name, - child_of: tracer.extract(OpenTracing::FORMAT_TEXT_MAP, @origin_carrier) - ) do |intermediate_scope| - @intermediate_scope = intermediate_scope - - @intermediate_carrier = {}.tap do |c| - tracer.inject(intermediate_scope.span.context, OpenTracing::FORMAT_TEXT_MAP, c) - end - - tracer.start_active_span( - destination_span_name, - child_of: tracer.extract(OpenTracing::FORMAT_TEXT_MAP, @intermediate_carrier) - ) do |destination_scope| - @destination_scope = destination_scope - # Do something - end - end - end - end - end - - it { expect(datadog_traces).to have(3).items } - it { expect(datadog_spans).to have(3).items } - - it { expect(origin_datadog_trace.sampling_priority).to eq(1) } - it { expect(origin_datadog_trace.origin).to eq('synthetics') } - it { expect(origin_datadog_span.finished?).to be(true) } - it { expect(origin_datadog_span.parent_id).to eq(0) } - - it { expect(intermediate_datadog_trace.sampling_priority).to eq(1) } - it { expect(intermediate_datadog_trace.origin).to eq('synthetics') } - it { expect(intermediate_datadog_span.finished?).to be(true) } - - it { - expect(intermediate_datadog_span.trace_id) - .to eq(low_order_trace_id(origin_datadog_span.trace_id)) - } - - it { expect(intermediate_datadog_span.parent_id).to eq(origin_datadog_span.id) } - it { expect(@intermediate_scope.span.context.baggage).to include(baggage) } - - it { expect(destination_datadog_trace.sampling_priority).to eq(1) } - it { expect(destination_datadog_trace.origin).to eq('synthetics') } - it { expect(destination_datadog_span.finished?).to be(true) } - it { expect(destination_datadog_span.trace_id).to eq(intermediate_datadog_span.trace_id) } - it { expect(destination_datadog_span.parent_id).to eq(intermediate_datadog_span.id) } - it { expect(@destination_scope.span.context.baggage).to include(baggage) } - - it do - expect(@origin_carrier).to include( - 'x-datadog-trace-id' => low_order_trace_id(origin_datadog_span.trace_id), - 'x-datadog-parent-id' => origin_datadog_span.id, - 'x-datadog-sampling-priority' => 1, - 'x-datadog-origin' => 'synthetics', - 'ot-baggage-account_name' => 'acme' - ) - end - - it do - expect(@intermediate_carrier).to include( - 'x-datadog-trace-id' => intermediate_datadog_span.trace_id, - 'x-datadog-parent-id' => intermediate_datadog_span.id, - 'x-datadog-sampling-priority' => 1, - 'x-datadog-origin' => 'synthetics', - 'ot-baggage-account_name' => 'acme' - ) - end - end - end - - describe 'via OpenTracing::FORMAT_RACK' do - def carrier_to_rack_format(carrier) - carrier.map { |k, v| [RackSupport.header_to_rack(k), v] }.to_h - end - - def baggage_to_carrier_format(baggage) - baggage.map { |k, v| [Datadog::OpenTracer::RackPropagator::BAGGAGE_PREFIX + k, v] }.to_h - end - - context 'when sending' do - let(:span_name) { 'operation.sender' } - let(:baggage) { { 'account_name' => 'acme' } } - let(:carrier) { {} } - - before do - tracer.start_active_span(span_name) do |scope| - scope.span.context.datadog_context.active_trace.sampling_priority = 1 - scope.span.context.datadog_context.active_trace.origin = 'synthetics' - baggage.each { |k, v| scope.span.set_baggage_item(k, v) } - tracer.inject( - scope.span.context, - OpenTracing::FORMAT_RACK, - carrier - ) - end - end - - it do - expect(carrier).to include( - 'x-datadog-trace-id' => a_kind_of(String), - 'x-datadog-parent-id' => a_kind_of(String), - 'x-datadog-sampling-priority' => a_kind_of(String), - 'x-datadog-origin' => a_kind_of(String) - ) - - expect(carrier['x-datadog-parent-id'].to_i).to be > 0 - - baggage.each do |k, v| - expect(carrier).to include(Datadog::OpenTracer::RackPropagator::BAGGAGE_PREFIX + k => v) - end - end - end - - context 'when receiving' do - let(:span_name) { 'operation.receiver' } - let(:baggage) { { 'account_name' => 'acme' } } - let(:baggage_with_prefix) { baggage_to_carrier_format(baggage) } - let(:carrier) { carrier_to_rack_format(baggage_with_prefix) } - - before do - span_context = tracer.extract(OpenTracing::FORMAT_RACK, carrier) - tracer.start_active_span(span_name, child_of: span_context) do |scope| - @scope = scope - # Do some work. - end - end - - context 'a carrier with valid headers' do - let(:carrier) do - super().merge( - carrier_to_rack_format( - 'x-datadog-trace-id' => trace_id.to_s, - 'x-datadog-parent-id' => parent_id.to_s, - 'x-datadog-sampling-priority' => sampling_priority.to_s, - 'x-datadog-origin' => origin.to_s - ) - ) - end - - let(:trace_id) { Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 1 } - let(:parent_id) { Datadog::Tracing::Utils::EXTERNAL_MAX_ID - 2 } - let(:sampling_priority) { 2 } - let(:origin) { 'synthetics' } - - let(:datadog_span) { datadog_spans.first } - let(:datadog_trace) { datadog_traces.first } - - it { expect(datadog_trace.sampling_priority).to eq(sampling_priority) } - it { expect(datadog_trace.origin).to eq('synthetics') } - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - it { expect(datadog_span.trace_id).to eq(trace_id) } - it { expect(datadog_span.parent_id).to eq(parent_id) } - it { expect(@scope.span.context.baggage).to include(baggage) } - end - - context 'a carrier with no headers' do - let(:carrier) { {} } - - let(:datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - it { expect(datadog_span.parent_id).to eq(0) } - end - end - - context 'in a round-trip' do - let(:origin_span_name) { 'operation.origin' } - let(:origin_datadog_trace) { datadog_traces.find { |x| x.name == origin_span_name } } - let(:origin_datadog_span) { datadog_spans.find { |x| x.name == origin_span_name } } - - let(:intermediate_span_name) { 'operation.intermediate' } - let(:intermediate_datadog_trace) { datadog_traces.find { |x| x.name == intermediate_span_name } } - let(:intermediate_datadog_span) { datadog_spans.find { |x| x.name == intermediate_span_name } } - - let(:destination_span_name) { 'operation.destination' } - let(:destination_datadog_trace) { datadog_traces.find { |x| x.name == destination_span_name } } - let(:destination_datadog_span) { datadog_spans.find { |x| x.name == destination_span_name } } - - # NOTE: If these baggage names include either dashes or uppercase characters - # they will not make a round-trip with the same key format. They will - # be converted to underscores and lowercase characters, because Rack - # forces everything to uppercase/dashes in transport causing resolution - # on key format to be lost. - let(:baggage) { { 'account_name' => 'acme' } } - - before do - tracer.start_active_span(origin_span_name) do |origin_scope| - origin_datadog_context = origin_scope.span.context.datadog_context - origin_datadog_context.active_trace.sampling_priority = 1 - origin_datadog_context.active_trace.origin = 'synthetics' - - baggage.each { |k, v| origin_scope.span.set_baggage_item(k, v) } - - @origin_carrier = {}.tap do |c| - tracer.inject(origin_scope.span.context, OpenTracing::FORMAT_RACK, c) - end - - origin_datadog_context.activate!(nil) do - tracer.start_active_span( - intermediate_span_name, - child_of: tracer.extract(OpenTracing::FORMAT_RACK, carrier_to_rack_format(@origin_carrier)) - ) do |intermediate_scope| - @intermediate_scope = intermediate_scope - - @intermediate_carrier = {}.tap do |c| - tracer.inject(intermediate_scope.span.context, OpenTracing::FORMAT_RACK, c) - end - - tracer.start_active_span( - destination_span_name, - child_of: tracer.extract(OpenTracing::FORMAT_RACK, carrier_to_rack_format(@intermediate_carrier)) - ) do |destination_scope| - @destination_scope = destination_scope - # Do something - end - end - end - end - end - - it { expect(datadog_traces).to have(3).items } - it { expect(datadog_spans).to have(3).items } - - it { expect(origin_datadog_trace.sampling_priority).to eq(1) } - it { expect(origin_datadog_span.finished?).to be(true) } - it { expect(origin_datadog_span.parent_id).to eq(0) } - - it { expect(intermediate_datadog_trace.sampling_priority).to eq(1) } - it { expect(intermediate_datadog_span.finished?).to be(true) } - it { expect(intermediate_datadog_span.trace_id).to eq(origin_datadog_span.trace_id) } - it { expect(intermediate_datadog_span.parent_id).to eq(origin_datadog_span.id) } - it { expect(@intermediate_scope.span.context.baggage).to include(baggage) } - - it { expect(destination_datadog_trace.sampling_priority).to eq(1) } - it { expect(destination_datadog_span.finished?).to be(true) } - it { expect(destination_datadog_span.trace_id).to eq(intermediate_datadog_span.trace_id) } - it { expect(destination_datadog_span.parent_id).to eq(intermediate_datadog_span.id) } - it { expect(@destination_scope.span.context.baggage).to include(baggage) } - - it do - expect(@origin_carrier).to include( - 'x-datadog-trace-id' => low_order_trace_id(origin_datadog_span.trace_id).to_s, - 'x-datadog-parent-id' => origin_datadog_span.id.to_s, - 'x-datadog-sampling-priority' => '1', - 'x-datadog-origin' => 'synthetics', - 'ot-baggage-account_name' => 'acme' - ) - end - - it do - expect(@intermediate_carrier).to include( - 'x-datadog-trace-id' => low_order_trace_id(intermediate_datadog_span.trace_id).to_s, - 'x-datadog-parent-id' => intermediate_datadog_span.id.to_s, - 'x-datadog-sampling-priority' => '1', - 'x-datadog-origin' => 'synthetics', - 'ot-baggage-account_name' => 'acme' - ) - end - end - end -end diff --git a/spec/datadog/opentracer/propagator_spec.rb b/spec/datadog/opentracer/propagator_spec.rb deleted file mode 100644 index 669d3e66c8b..00000000000 --- a/spec/datadog/opentracer/propagator_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::Propagator do - describe 'implemented class behavior' do - subject(:propagator_class) do - stub_const( - 'TestPropagator', - Class.new.tap do |klass| - klass.extend(described_class) - end - ) - end - - describe '#inject' do - let(:span_context) { instance_double(Datadog::OpenTracer::SpanContext) } - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - - it { expect { propagator_class.inject(span_context, carrier) }.to raise_error(NotImplementedError) } - end - - describe '#extract' do - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - - it { expect { propagator_class.extract(carrier) }.to raise_error(NotImplementedError) } - end - end -end diff --git a/spec/datadog/opentracer/rack_propagator_spec.rb b/spec/datadog/opentracer/rack_propagator_spec.rb deleted file mode 100644 index eb185ca749b..00000000000 --- a/spec/datadog/opentracer/rack_propagator_spec.rb +++ /dev/null @@ -1,173 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing/context' -require 'datadog/tracing/utils' -require 'datadog/tracing/contrib/http' -require 'datadog/tracing/trace_digest' -require 'datadog/tracing/trace_operation' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::RackPropagator do - describe '#inject' do - subject { described_class.inject(span_context, carrier) } - - let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id } - let(:span_id) { double('span ID') } - let(:sampling_decision) { '-1' } - let(:sampling_priority) { double('sampling priority') } - let(:origin) { double('synthetics') } - let(:trace_distributed_tags) { { '_dd.p.key' => 'value', '_dd.p.dm' => sampling_decision } } - - let(:baggage) { { 'account_name' => 'acme' } } - - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - - before do - Datadog.configure do |c| - c.tracing.propagation_style = ['datadog'] - end - - # Expect carrier to be set with Datadog trace properties - expect(carrier).to receive(:[]=) - .with('x-datadog-trace-id', low_order_trace_id(trace_id).to_s) - expect(carrier).to receive(:[]=) - .with('x-datadog-parent-id', span_id.to_s) - expect(carrier).to receive(:[]=) - .with('x-datadog-sampling-priority', sampling_priority.to_s) - expect(carrier).to receive(:[]=) - .with('x-datadog-origin', origin.to_s) - expect(carrier).to receive(:[]=) - .with('x-datadog-tags', - '_dd.p.key=value,_dd.p.dm=-1,_dd.p.tid=' + - high_order_hex_trace_id(trace_id)) - - # Expect carrier to be set with OpenTracing baggage - baggage.each do |key, value| - expect(carrier).to receive(:[]=) - .with(described_class::BAGGAGE_PREFIX + key, value) - end - end - - context 'when given span context with datadog context' do - let(:span_context) do - instance_double( - Datadog::OpenTracer::SpanContext, - datadog_context: datadog_context, - baggage: baggage - ) - end - - let(:datadog_context) do - instance_double( - Datadog::Tracing::Context, - active_trace: datadog_trace - ) - end - - let(:datadog_trace) do - Datadog::Tracing::TraceOperation.new( - id: trace_id, - parent_span_id: span_id, - sampling_priority: sampling_priority, - origin: origin, - tags: trace_distributed_tags - ) - end - - it { is_expected.to be nil } - end - - context 'when given span context with datadog trace digest' do - let(:span_context) do - instance_double( - Datadog::OpenTracer::SpanContext, - datadog_context: nil, - datadog_trace_digest: datadog_trace_digest, - baggage: baggage - ) - end - - let(:datadog_trace_digest) do - instance_double( - Datadog::Tracing::TraceDigest, - span_id: span_id, - trace_id: trace_id, - trace_origin: origin, - trace_sampling_priority: sampling_priority, - trace_distributed_tags: trace_distributed_tags, - ) - end - it { is_expected.to be nil } - end - end - - describe '#extract' do - subject(:span_context) { described_class.extract(carrier) } - - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - let(:items) { {} } - let(:datadog_trace_digest) do - instance_double( - Datadog::Tracing::TraceDigest, - span_id: double('span ID'), - trace_id: double('trace ID'), - trace_origin: double('origin'), - trace_sampling_priority: double('sampling priority'), - trace_distributed_tags: double('trace_distributed_tags'), - ) - end - - before do - expect(Datadog::Tracing::Contrib::HTTP).to receive(:extract) - .with(carrier) - .and_return(datadog_trace_digest) - - allow(carrier).to receive(:each) { |&block| items.each(&block) } - end - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - - context 'when the carrier contains' do - context 'baggage' do - let(:value) { 'acme' } - let(:items) { { key => value } } - - before do - items.each do |key, value| - allow(carrier).to receive(:[]).with(key).and_return(value) - end - end - - context 'with a symbol' do - context 'that does not have a proper prefix' do - let(:key) { :my_baggage_item } - - it { expect(span_context.baggage).to be_empty } - end - - context 'that has a proper prefix' do - let(:key) { :"#{described_class::BAGGAGE_PREFIX_FORMATTED}ACCOUNT_NAME" } - - it { expect(span_context.baggage).to have(1).items } - it { expect(span_context.baggage).to include('account_name' => value) } - end - end - - context 'with a string' do - context 'that does not have a proper prefix' do - let(:key) { 'HTTP_ACCOUNT_NAME' } - - it { expect(span_context.baggage).to be_empty } - end - - context 'that has a proper prefix' do - let(:key) { "#{described_class::BAGGAGE_PREFIX_FORMATTED}ACCOUNT_NAME" } - - it { expect(span_context.baggage).to have(1).items } - it { expect(span_context.baggage).to include('account_name' => value) } - end - end - end - end - end -end diff --git a/spec/datadog/opentracer/scope_manager_spec.rb b/spec/datadog/opentracer/scope_manager_spec.rb deleted file mode 100644 index 3a281647a74..00000000000 --- a/spec/datadog/opentracer/scope_manager_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::ScopeManager do - subject(:scope_manager) { described_class.new } - - describe '#activate' do - subject(:activate) { scope_manager.activate(span, finish_on_close: finish_on_close) } - - let(:span) { instance_double(Datadog::OpenTracer::Span) } - let(:finish_on_close) { true } - - it { is_expected.to be(OpenTracing::Scope::NOOP_INSTANCE) } - end - - describe '#activate' do - subject(:active) { scope_manager.active } - - it { is_expected.to be(OpenTracing::Scope::NOOP_INSTANCE) } - end -end diff --git a/spec/datadog/opentracer/scope_spec.rb b/spec/datadog/opentracer/scope_spec.rb deleted file mode 100644 index aac759deaa5..00000000000 --- a/spec/datadog/opentracer/scope_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::Scope do - subject(:scope) { described_class.new(manager: manager, span: span) } - - let(:manager) { instance_double(Datadog::OpenTracer::ScopeManager) } - let(:span) { instance_double(Datadog::OpenTracer::Span) } - - it do - is_expected.to have_attributes( - manager: manager, - span: span - ) - end - - describe '#close' do - subject(:result) { scope.close } - - it { is_expected.to be nil } - end -end diff --git a/spec/datadog/opentracer/span_context_factory_spec.rb b/spec/datadog/opentracer/span_context_factory_spec.rb deleted file mode 100644 index 29fb4c760ba..00000000000 --- a/spec/datadog/opentracer/span_context_factory_spec.rb +++ /dev/null @@ -1,153 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing/context' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::SpanContextFactory do - describe 'class methods' do - describe '#build' do - context 'given Datadog::Tracing::Context' do - subject(:span_context) do - described_class.build( - datadog_context: datadog_context, - datadog_trace_digest: datadog_trace_digest - ) - end - - let(:datadog_context) { instance_double(Datadog::Tracing::Context) } - let(:datadog_trace_digest) { instance_double(Datadog::Tracing::TraceDigest) } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - - describe 'builds a SpanContext where' do - it { expect(span_context.datadog_context).to be(datadog_context) } - it { expect(span_context.datadog_trace_digest).to be(datadog_trace_digest) } - - describe '#baggage' do - subject(:baggage) { span_context.baggage } - - it { is_expected.to be_a_kind_of(Hash) } - it { is_expected.to be_empty } - end - end - - context 'and baggage' do - subject(:span_context) do - described_class.build( - datadog_context: datadog_context, - datadog_trace_digest: datadog_trace_digest, - baggage: original_baggage - ) - end - - let(:original_baggage) { { 'account_id' => '1234' } } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - - describe 'builds a SpanContext where' do - it { expect(span_context.datadog_context).to be(datadog_context) } - - describe '#baggage' do - subject(:baggage) { span_context.baggage } - - it { is_expected.to be_a_kind_of(Hash) } - - context 'when the original baggage contains data' do - it { is_expected.to include('account_id' => '1234') } - it { is_expected.to_not be(original_baggage) } - end - end - end - end - end - end - - describe '#clone' do - context 'given a SpanContext' do - subject(:span_context) { described_class.clone(span_context: original_span_context) } - - let(:original_span_context) do - instance_double( - Datadog::OpenTracer::SpanContext, - datadog_context: original_datadog_context, - datadog_trace_digest: original_datadog_trace_digest, - baggage: original_baggage - ) - end - let(:original_datadog_context) { instance_double(Datadog::Tracing::Context) } - let(:original_datadog_trace_digest) { instance_double(Datadog::Tracing::TraceDigest) } - let(:original_baggage) { {} } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - - describe 'builds a SpanContext where' do - it { expect(span_context.datadog_context).to be(original_datadog_context) } - it { expect(span_context.datadog_trace_digest).to be(original_datadog_trace_digest) } - - describe '#baggage' do - subject(:baggage) { span_context.baggage } - - it { is_expected.to be_a_kind_of(Hash) } - - context 'when the original SpanContext contains baggage' do - let(:original_baggage) { { 'org_id' => '4321' } } - - it { is_expected.to include('org_id' => '4321') } - it { is_expected.to_not be(original_baggage) } - end - end - end - - context 'and baggage' do - subject(:span_context) { described_class.clone(span_context: original_span_context, baggage: param_baggage) } - - let(:param_baggage) { {} } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - - describe 'builds a SpanContext where' do - describe '#baggage' do - subject(:baggage) { span_context.baggage } - - it { is_expected.to be_a_kind_of(Hash) } - - context 'when the original SpanContext contains baggage' do - let(:original_baggage) { { 'org_id' => '4321' } } - - it { is_expected.to include('org_id' => '4321') } - it { is_expected.to_not be(original_baggage) } - end - - context 'when the original baggage contains data' do - let(:param_baggage) { { 'account_id' => '1234' } } - - it { is_expected.to include('account_id' => '1234') } - it { is_expected.to_not be(param_baggage) } - end - - context 'when the original SpanContext baggage and param baggage contains data' do - context 'that doesn\'t overlap' do - let(:original_baggage) { { 'org_id' => '4321' } } - let(:param_baggage) { { 'account_id' => '1234' } } - - it { is_expected.to include('org_id' => '4321', 'account_id' => '1234') } - it { is_expected.to_not be(original_baggage) } - it { is_expected.to_not be(param_baggage) } - end - - context 'that overlaps' do - let(:original_baggage) { { 'org_id' => '4321' } } - let(:param_baggage) { { 'org_id' => '1234' } } - - it { is_expected.to include('org_id' => '1234') } - it { is_expected.to_not be(original_baggage) } - it { is_expected.to_not be(param_baggage) } - end - end - end - end - end - end - end - end -end diff --git a/spec/datadog/opentracer/span_context_spec.rb b/spec/datadog/opentracer/span_context_spec.rb deleted file mode 100644 index 63bc1741285..00000000000 --- a/spec/datadog/opentracer/span_context_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing/context' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::SpanContext do - describe '#initialize' do - context 'given a Datadog::Context' do - subject(:span_context) { described_class.new(datadog_context: datadog_context) } - - let(:datadog_context) { instance_double(Datadog::Tracing::Context) } - - it do - is_expected.to have_attributes( - datadog_context: datadog_context, - baggage: {} - ) - end - - context 'and baggage' do - subject(:span_context) do - described_class.new( - datadog_context: datadog_context, - baggage: original_baggage - ) - end - - let(:original_baggage) { { account_id: '1234' } } - - it { is_expected.to be_a_kind_of(described_class) } - - describe 'builds a SpanContext where' do - describe '#baggage' do - subject(:baggage) { span_context.baggage } - - it { is_expected.to be(original_baggage) } - - it 'is immutable' do - expect { baggage[1] = 2 }.to raise_error(RuntimeError) - end - end - end - end - end - end -end diff --git a/spec/datadog/opentracer/span_spec.rb b/spec/datadog/opentracer/span_spec.rb deleted file mode 100644 index ab8e0ddef86..00000000000 --- a/spec/datadog/opentracer/span_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -require 'spec_helper' - -require 'time' - -require 'datadog/tracing/metadata/ext' -require 'datadog/tracing/span_operation' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::Span do - subject(:span) { described_class.new(datadog_span: datadog_span, span_context: span_context) } - - let(:datadog_span) { instance_double(Datadog::Tracing::SpanOperation) } - let(:span_context) { instance_double(Datadog::OpenTracer::SpanContext) } - - describe '#operation_name=' do - subject(:result) { span.operation_name = name } - - let(:name) { 'execute_job' } - - before { expect(datadog_span).to receive(:name=).with(name).and_return(name) } - - it { expect(result).to eq(name) } - end - - describe '#context' do - subject(:context) { span.context } - - it { is_expected.to be(span_context) } - end - - describe '#set_tag' do - subject(:result) { span.set_tag(key, value) } - - context 'when given arbitrary tag key and value' do - let(:key) { 'account_id' } - let(:value) { '1234' } - - before { expect(datadog_span).to receive(:set_tag).with(key, value) } - - it { is_expected.to be(span) } - end - - context 'when given an error tag of true' do - let(:key) { 'error' } - let(:value) { true } - - before { expect(datadog_span).to receive(:set_tag).with(key, value) } - - before { expect(datadog_span).to receive(:'status=').with(Datadog::Tracing::Metadata::Ext::Errors::STATUS) } - - it { is_expected.to be(span) } - end - - context 'when given an error tag of false' do - let(:key) { 'error' } - let(:value) { false } - - before { expect(datadog_span).to receive(:set_tag).with(key, value) } - - before { expect(datadog_span).to receive(:'status=').with(0) } - - it { is_expected.to be(span) } - end - end - - describe '#set_baggage_item' do - subject(:result) { span.set_baggage_item(key, value) } - - let(:key) { 'account_id' } - let(:value) { '1234' } - let(:new_span_context) { instance_double(Datadog::OpenTracer::SpanContext) } - - it 'creates a new SpanContext with the baggage item' do - expect(Datadog::OpenTracer::SpanContextFactory).to receive(:clone) - .with(span_context: span_context, baggage: hash_including(key => value)) - .and_return(new_span_context) - - is_expected.to be(span) - expect(span.context).to be(new_span_context) - end - end - - describe '#get_baggage_item' do - subject(:result) { span.get_baggage_item(key) } - - let(:key) { 'account_id' } - let(:value) { '1234' } - let(:baggage) { { key => value } } - - before { allow(span_context).to receive(:baggage).and_return(baggage) } - - it { is_expected.to be(value) } - end - - describe '#log' do - subject(:log) { span.log(event: event, timestamp: timestamp, **fields) } - - let(:event) { 'job_finished' } - let(:timestamp) { Time.now } - let(:fields) { { time_started: Time.now, account_id: '1234' } } - - # Expect a deprecation warning to be output. - it do - expect { log }.to output("Span#log is deprecated. Please use Span#log_kv instead.\n").to_stderr - end - end - - describe '#log_kv' do - subject(:log_kv) { span.log_kv(timestamp: timestamp, **fields) } - - let(:timestamp) { Time.now } - - context 'when given arbitrary key/value pairs' do - let(:fields) { { time_started: Time.now, account_id: '1234' } } - # We don't expect this to do anything right now. - - it { is_expected.to be nil } - end - - context 'when given an \'error.object\'' do - let(:fields) { { :'error.object' => error_object } } - let(:error_object) { instance_double(StandardError) } - - before { expect(datadog_span).to receive(:set_error).with(error_object) } - - it { is_expected.to be nil } - end - end -end diff --git a/spec/datadog/opentracer/text_map_propagator_spec.rb b/spec/datadog/opentracer/text_map_propagator_spec.rb deleted file mode 100644 index c50fe49c749..00000000000 --- a/spec/datadog/opentracer/text_map_propagator_spec.rb +++ /dev/null @@ -1,202 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing/context' -require 'datadog/tracing/trace_operation' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::TextMapPropagator do - describe '#inject' do - let(:trace_id) { 4363611732769921584 } - let(:span_id) { 2352279000849524039 } - let(:sampling_priority) { 1 } - let(:origin) { 'synthetics' } - - let(:baggage) { { 'account_name' => 'acme' } } - - context 'when given span context with datadog context' do - let(:span_context) do - instance_double( - Datadog::OpenTracer::SpanContext, - datadog_context: datadog_context, - baggage: baggage - ) - end - - let(:datadog_context) do - instance_double( - Datadog::Tracing::Context, - active_trace: datadog_trace - ) - end - - let(:datadog_trace) do - Datadog::Tracing::TraceOperation.new( - id: trace_id, - parent_span_id: span_id, - sampling_priority: sampling_priority, - origin: origin - ) - end - - it 'sets the carrier correctly' do - carrier = double.tap { |d| allow(d).to receive(:[]=) } - - described_class.inject(span_context, carrier) - - baggage.each do |key, value| - expect(carrier).to have_received(:[]=) - .with(described_class::BAGGAGE_PREFIX + key, value) - end - - expect(carrier).to have_received(:[]=) - .with('x-datadog-trace-id', trace_id) - expect(carrier).to have_received(:[]=) - .with('x-datadog-parent-id', span_id) - expect(carrier).to have_received(:[]=) - .with('x-datadog-sampling-priority', sampling_priority) - expect(carrier).to have_received(:[]=) - .with('x-datadog-origin', origin) - end - end - - context 'when given span context with datadog trace digest' do - let(:span_context) do - instance_double( - Datadog::OpenTracer::SpanContext, - datadog_context: nil, - datadog_trace_digest: datadog_trace_digest, - baggage: baggage - ) - end - - let(:datadog_trace_digest) do - instance_double( - Datadog::Tracing::TraceDigest, - span_id: span_id, - trace_id: trace_id, - trace_origin: origin, - trace_sampling_priority: sampling_priority - ) - end - - it 'sets the carrier correctly' do - carrier = double.tap { |d| allow(d).to receive(:[]=) } - - described_class.inject(span_context, carrier) - - baggage.each do |key, value| - expect(carrier).to have_received(:[]=) - .with(described_class::BAGGAGE_PREFIX + key, value) - end - - expect(carrier).to have_received(:[]=) - .with('x-datadog-trace-id', trace_id) - expect(carrier).to have_received(:[]=) - .with('x-datadog-parent-id', span_id) - expect(carrier).to have_received(:[]=) - .with('x-datadog-sampling-priority', sampling_priority) - expect(carrier).to have_received(:[]=) - .with('x-datadog-origin', origin) - end - end - end - - describe '#extract' do - subject(:span_context) { described_class.extract(carrier) } - - let(:carrier) { instance_double(Datadog::OpenTracer::Carrier) } - let(:items) { {} } - let(:datadog_context) { span_context.datadog_context } - let(:datadog_trace_digest) { span_context.datadog_trace_digest } - - before do - allow(carrier).to receive(:each) { |&block| items.each(&block) } - end - - context 'when the carrier contains' do - before do - allow(Datadog::OpenTracer::DistributedHeaders).to receive(:new) - .with(carrier) - .and_return(headers) - end - - shared_examples_for 'baggage' do - let(:value) { 'acme' } - let(:items) { { key => value } } - - context 'with a symbol' do - context 'that does not have a proper prefix' do - let(:key) { :my_baggage_item } - - it { expect(span_context.baggage).to be_empty } - end - - context 'that has a proper prefix' do - let(:key) { :"#{described_class::BAGGAGE_PREFIX}account_name" } - - it { expect(span_context.baggage).to have(1).items } - it { expect(span_context.baggage).to include('account_name' => value) } - end - end - - context 'with a string' do - context 'that does not have a proper prefix' do - let(:key) { 'HTTP_ACCOUNT_NAME' } - - it { expect(span_context.baggage).to be_empty } - end - - context 'that has a proper prefix' do - let(:key) { "#{described_class::BAGGAGE_PREFIX}account_name" } - - it { expect(span_context.baggage).to have(1).items } - it { expect(span_context.baggage).to include('account_name' => value) } - end - end - end - - context 'invalid Datadog headers' do - let(:headers) do - instance_double( - Datadog::OpenTracer::DistributedHeaders, - valid?: false - ) - end - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - it { expect(datadog_context).to be nil } - it { expect(datadog_trace_digest).to be nil } - - it_behaves_like 'baggage' - end - - context 'valid Datadog headers' do - let(:headers) do - instance_double( - Datadog::OpenTracer::DistributedHeaders, - valid?: true, - trace_id: trace_id, - parent_id: parent_id, - sampling_priority: sampling_priority, - origin: origin - ) - end - - let(:trace_id) { 123 } - let(:parent_id) { 456 } - let(:sampling_priority) { 1 } - let(:origin) { 'my-origin' } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::SpanContext) } - it { expect(datadog_context).to be nil } - it { expect(datadog_trace_digest).to be_a_kind_of(Datadog::Tracing::TraceDigest) } - it { expect(datadog_trace_digest.span_id).to eq parent_id } - it { expect(datadog_trace_digest.trace_id).to eq trace_id } - it { expect(datadog_trace_digest.trace_origin).to eq origin } - it { expect(datadog_trace_digest.trace_sampling_priority).to eq sampling_priority } - - it_behaves_like 'baggage' - end - end - end -end diff --git a/spec/datadog/opentracer/thread_local_scope_manager_spec.rb b/spec/datadog/opentracer/thread_local_scope_manager_spec.rb deleted file mode 100644 index 34805f36701..00000000000 --- a/spec/datadog/opentracer/thread_local_scope_manager_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::ThreadLocalScopeManager do - subject(:scope_manager) { described_class.new } - - describe '#activate' do - subject(:activate) { scope_manager.activate(span, finish_on_close: finish_on_close) } - - let(:scope) { activate } - let(:span) { instance_double(Datadog::OpenTracer::Span) } - let(:finish_on_close) { true } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::ThreadLocalScope) } - it { expect(scope.manager).to be(scope_manager) } - it { expect(scope.span).to be(span) } - end - - describe '#activate' do - subject(:active) { scope_manager.active } - - context 'when no scope has been activated' do - it { is_expected.to be nil } - end - - context 'when a scope has been activated' do - let(:scope) { scope_manager.activate(span, finish_on_close: finish_on_close) } - let(:span) { instance_double(Datadog::OpenTracer::Span) } - let(:finish_on_close) { true } - - before { scope } # Activate a scope - - it { is_expected.to be(scope) } - end - end -end diff --git a/spec/datadog/opentracer/thread_local_scope_spec.rb b/spec/datadog/opentracer/thread_local_scope_spec.rb deleted file mode 100644 index d75cbbc4f10..00000000000 --- a/spec/datadog/opentracer/thread_local_scope_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::ThreadLocalScope do - subject(:scope) do - described_class.new( - manager: manager, - span: span, - finish_on_close: finish_on_close - ) - end - - let(:manager) { Datadog::OpenTracer::ThreadLocalScopeManager.new } - let(:span) { instance_double(Datadog::OpenTracer::Span) } - let(:finish_on_close) { true } - let(:previous_scope) { nil } - - before do - allow(manager).to receive(:active) do - # Unstub after first call - allow(manager).to receive(:active).and_call_original - previous_scope - end - end - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::Scope) } - it { is_expected.to have_attributes(finish_on_close: finish_on_close) } - - describe '#close' do - subject(:close) { scope.close } - - context 'when the scope is' do - before do - scope # Initialize the scope, to prevent overstubbing the previous stub - allow(manager).to receive(:active).and_return(active_scope) - end - - context 'active' do - let(:active_scope) { scope } - - context 'and #finish_on_close' do - context 'is true' do - let(:finish_on_close) { true } - - it 'finishes the span and restores the previous scope' do - expect(span).to receive(:finish) - expect(manager).to receive(:set_scope).with(previous_scope) - scope.close - end - end - - context 'is false' do - let(:finish_on_close) { false } - - it 'does not finish the span but restores the previous scope' do - expect(span).to_not receive(:finish) - expect(manager).to receive(:set_scope).with(previous_scope) - scope.close - end - end - end - end - - context 'not active' do - let(:active_scope) { instance_double(described_class) } - - it 'does nothing' do - expect(span).to_not receive(:finish) - expect(manager).to_not receive(:set_scope) - scope.close - end - end - end - end -end diff --git a/spec/datadog/opentracer/tracer_integration_spec.rb b/spec/datadog/opentracer/tracer_integration_spec.rb deleted file mode 100644 index 77644a7a558..00000000000 --- a/spec/datadog/opentracer/tracer_integration_spec.rb +++ /dev/null @@ -1,411 +0,0 @@ -require 'spec_helper' - -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::Tracer do - subject(:tracer) { described_class.new(writer: writer) } - - let(:writer) { FauxWriter.new } - let(:datadog_tracer) { tracer.datadog_tracer } - let(:datadog_spans) { datadog_tracer.writer.spans(:keep) } - - after { writer.stop } - - def current_context_for(object) - case object - when Datadog::OpenTracer::Span - object.context.datadog_context - when Datadog::OpenTracer::SpanContext - object.datadog_context - when Datadog::OpenTracer::Scope - object.span.context.datadog_context - end - end - - def current_trace_for(object) - case object - when Datadog::OpenTracer::Span - object.context.datadog_context.active_trace - when Datadog::OpenTracer::SpanContext - object.datadog_context.active_trace - when Datadog::OpenTracer::Scope - object.span.context.datadog_context.active_trace - end - end - - def current_span_for(object) - case object - when Datadog::OpenTracer::Span - object.datadog_span - when Datadog::OpenTracer::SpanContext - object.datadog_context.active_span - when Datadog::OpenTracer::Scope - object.span.datadog_span - end - end - - describe '#start_span' do - context 'for a single span' do - context 'without a block' do - let(:span) { tracer.start_span(span_name, **options) } - let(:datadog_span) { datadog_spans.first } - let(:span_name) { 'operation.foo' } - let(:options) { {} } - - before { span.finish } - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - - context 'when given start_time' do - let(:options) { { start_time: start_time } } - let(:start_time) { Time.utc(2000, 1, 1) } - - it { expect(datadog_span.start_time).to be(start_time) } - end - - context 'when given tags' do - let(:options) { { tags: tags } } - let(:tags) { { 'operation.type' => 'validate', 'account_id' => 1 } } - - it { tags.each { |k, v| expect(datadog_span.get_tag(k)).to eq(v.is_a?(Numeric) ? v.to_f : v) } } - end - end - end - - context 'for a nested span' do - context 'when there is no active scope' do - before do - tracer.start_span('operation.outer').tap do |outer_span| - tracer.start_span('operation.inner').tap do |inner_span| - # Assert Datadog context integrity - # They should be in their own traces. - expect(current_context_for(inner_span)).to_not be(current_context_for(outer_span)) - expect(current_trace_for(inner_span)).to_not be(current_trace_for(outer_span)) - end.finish - end.finish - end - - let(:outer_datadog_span) { datadog_spans.last } - let(:inner_datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(2).items } - it { expect(outer_datadog_span.name).to eq('operation.outer') } - it { expect(outer_datadog_span.parent_id).to eq(0) } - it { expect(outer_datadog_span.finished?).to be true } - it { expect(inner_datadog_span.name).to eq('operation.inner') } - it { expect(inner_datadog_span.parent_id).to eq(0) } - it { expect(inner_datadog_span.finished?).to be true } - end - - context 'when there is an active scope' do - context 'which is used' do - before do - tracer.start_active_span('operation.parent') do |parent_scope| - tracer.start_span('operation.child').tap do |span| - # Assert Datadog context integrity - expect(current_context_for(parent_scope)).to be(current_context_for(span)) - expect(current_trace_for(parent_scope)).to be(current_trace_for(span)) - end.finish - end - end - - let(:parent_datadog_span) { datadog_spans.last } - let(:child_datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(2).items } - it { expect(parent_datadog_span.name).to eq('operation.parent') } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be true } - it { expect(child_datadog_span.name).to eq('operation.child') } - it { expect(child_datadog_span.parent_id).to eq(parent_datadog_span.id) } - it { expect(child_datadog_span.finished?).to be true } - end - - context 'which is ignored' do - before do - tracer.start_active_span('operation.parent') do |scope| - tracer.start_span('operation.child', ignore_active_scope: true).tap do |span| - # Assert Datadog context integrity - expect(current_context_for(scope)).to_not be(current_context_for(span)) - expect(current_trace_for(scope)).to_not be(current_trace_for(span)) - end.finish - end - end - - let(:parent_datadog_span) { datadog_spans.last } - let(:child_datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(2).items } - it { expect(parent_datadog_span.name).to eq('operation.parent') } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be true } - it { expect(child_datadog_span.name).to eq('operation.child') } - it { expect(child_datadog_span.parent_id).to eq(0) } - it { expect(child_datadog_span.finished?).to be true } - end - end - - context 'manually associated with child_of' do - before do - tracer.start_span('operation.parent').tap do |parent_span| - tracer.start_active_span('operation.fake_parent') do - tracer.start_span('operation.child', child_of: parent_span).tap do |span| - # Assert Datadog context integrity - expect(current_context_for(parent_span)).to be(current_context_for(span)) - expect(current_trace_for(parent_span)).to be(current_trace_for(span)) - end.finish - end - end.finish - end - - let(:parent_datadog_span) { datadog_spans[2] } - let(:fake_parent_datadog_span) { datadog_spans[1] } - let(:child_datadog_span) { datadog_spans[0] } - - it { expect(datadog_spans).to have(3).items } - it { expect(parent_datadog_span.name).to eq('operation.parent') } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be true } - it { expect(child_datadog_span.name).to eq('operation.child') } - it { expect(child_datadog_span.parent_id).to eq(parent_datadog_span.id) } - it { expect(child_datadog_span.finished?).to be true } - end - end - - context 'for sibling span' do - before do - tracer.start_span('operation.older_sibling').finish - tracer.start_span('operation.younger_sibling').tap do |span| - # Assert Datadog context integrity - # There shouldn't be an active trace - expect(current_trace_for(span)).to_not be nil - end.finish - end - - let(:older_datadog_span) { datadog_spans.first } - let(:younger_datadog_span) { datadog_spans.last } - - it { expect(datadog_spans).to have(2).items } - it { expect(older_datadog_span.name).to eq('operation.older_sibling') } - it { expect(older_datadog_span.parent_id).to eq(0) } - it { expect(older_datadog_span.finished?).to be true } - it { expect(younger_datadog_span.name).to eq('operation.younger_sibling') } - it { expect(younger_datadog_span.parent_id).to eq(0) } - it { expect(younger_datadog_span.finished?).to be true } - end - end - - describe '#start_active_span' do - let(:span_name) { 'operation.foo' } - let(:options) { {} } - - context 'for a single span' do - context 'without a block' do - before { tracer.start_active_span(span_name, **options).close } - - let(:datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - - context 'when given start_time' do - let(:options) { { start_time: start_time } } - let(:start_time) { Time.utc(2000, 1, 1) } - - it { expect(datadog_span.start_time).to be(start_time) } - end - - context 'when given tags' do - let(:options) { { tags: tags } } - let(:tags) { { 'operation.type' => 'validate', 'account_id' => 1 } } - - it { tags.each { |k, v| expect(datadog_span.get_tag(k)).to eq(v.is_a?(Numeric) ? v.to_f : v) } } - end - end - - context 'with a block' do - before { tracer.start_active_span(span_name, **options) { |scope| @scope = scope } } - - let(:datadog_span) { datadog_spans.first } - - it do - expect { |b| tracer.start_active_span(span_name, &b) }.to yield_with_args( - a_kind_of(Datadog::OpenTracer::Scope) - ) - end - - it { expect(datadog_spans).to have(1).items } - it { expect(datadog_span.name).to eq(span_name) } - it { expect(datadog_span.finished?).to be(true) } - - context 'when given finish_on_close' do - context 'as true' do - let(:options) { { finish_on_close: true } } - - it { expect(datadog_span.finished?).to be(true) } - end - - context 'as false' do - let(:options) { { finish_on_close: false } } - let(:datadog_span) { @scope.span.datadog_span } - - it { expect(datadog_span.finished?).to be(false) } - end - end - end - - context 'preceded by a Datadog span' do - let(:parent_span_name) { 'operation.bar' } - let(:parent_datadog_span) { datadog_spans.first } - let(:child_datadog_span) { datadog_spans.last } - let(:options) { { finish_on_close: true } } - - before do - datadog_tracer.trace(parent_span_name) do |span| - @parent_span = span - tracer.start_active_span(span_name, **options) do |scope| - @scope = scope - end - end - end - - it { expect(datadog_spans).to have(2).items } - it { expect(parent_datadog_span.name).to eq(parent_span_name) } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be(true) } - it { expect(child_datadog_span.name).to eq(span_name) } - it { expect(child_datadog_span.parent_id).to eq(parent_datadog_span.id) } - it { expect(child_datadog_span.finished?).to be(true) } - it { expect(child_datadog_span.trace_id).to eq(parent_datadog_span.trace_id) } - end - - context 'followed by a Datadog span' do - let(:child_span_name) { 'operation.bar' } - let(:parent_datadog_span) { datadog_spans.last } - let(:child_datadog_span) { datadog_spans.first } - let(:options) { { finish_on_close: true } } - - before do - tracer.start_active_span(span_name, **options) do |scope| - @scope = scope - datadog_tracer.trace(child_span_name) do |span| - @child_span = span - end - end - end - - it { expect(datadog_spans).to have(2).items } - it { expect(parent_datadog_span.name).to eq(span_name) } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be(true) } - it { expect(child_datadog_span.name).to eq(child_span_name) } - it { expect(child_datadog_span.parent_id).to eq(parent_datadog_span.id) } - it { expect(child_datadog_span.finished?).to be(true) } - it { expect(child_datadog_span.trace_id).to eq(parent_datadog_span.trace_id) } - end - end - - context 'for a nested span' do - context 'when there is an active scope' do - context 'which is used' do - before do - tracer.start_active_span('operation.parent') do |parent_scope| - tracer.start_active_span('operation.child') do |scope| - # Assert Datadog context integrity - expect(current_context_for(parent_scope)).to be(current_context_for(scope)) - expect(current_trace_for(parent_scope)).to be(current_trace_for(scope)) - end - end - end - - let(:parent_datadog_span) { datadog_spans.last } - let(:child_datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(2).items } - it { expect(parent_datadog_span.name).to eq('operation.parent') } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be true } - it { expect(child_datadog_span.name).to eq('operation.child') } - it { expect(child_datadog_span.parent_id).to eq(parent_datadog_span.id) } - it { expect(child_datadog_span.finished?).to be true } - end - - context 'which is ignored' do - before do - tracer.start_active_span('operation.parent') do |parent_scope| - tracer.start_active_span('operation.child', ignore_active_scope: true) do |scope| - # Assert Datadog context integrity - expect(current_context_for(parent_scope)).to_not be(current_context_for(scope)) - expect(current_trace_for(parent_scope)).to_not be(current_trace_for(scope)) - end - end - end - - let(:parent_datadog_span) { datadog_spans.last } - let(:child_datadog_span) { datadog_spans.first } - - it { expect(datadog_spans).to have(2).items } - it { expect(parent_datadog_span.name).to eq('operation.parent') } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be true } - it { expect(child_datadog_span.name).to eq('operation.child') } - it { expect(child_datadog_span.parent_id).to eq(0) } - it { expect(child_datadog_span.finished?).to be true } - end - end - - context 'manually associated with child_of' do - before do - tracer.start_span('operation.parent').tap do |parent_span| - tracer.start_active_span('operation.fake_parent') do |_fake_parent_span| - tracer.start_active_span('operation.child', child_of: parent_span) do |scope| - # Assert Datadog context integrity - expect(current_context_for(parent_span)).to be(current_context_for(scope)) - expect(current_trace_for(parent_span)).to be(current_trace_for(scope)) - end - end - end.finish - end - - let(:parent_datadog_span) { datadog_spans[2] } - let(:fake_parent_datadog_span) { datadog_spans[1] } - let(:child_datadog_span) { datadog_spans[0] } - - it { expect(datadog_spans).to have(3).items } - it { expect(parent_datadog_span.name).to eq('operation.parent') } - it { expect(parent_datadog_span.parent_id).to eq(0) } - it { expect(parent_datadog_span.finished?).to be true } - it { expect(child_datadog_span.name).to eq('operation.child') } - it { expect(child_datadog_span.parent_id).to eq(parent_datadog_span.id) } - it { expect(child_datadog_span.finished?).to be true } - it { expect(fake_parent_datadog_span.name).to eq('operation.fake_parent') } - it { expect(fake_parent_datadog_span.parent_id).to eq(0) } - it { expect(fake_parent_datadog_span.finished?).to be true } - end - end - - context 'for sibling span' do - before do - tracer.start_active_span('operation.older_sibling') { |scope| } - tracer.start_active_span('operation.younger_sibling') do |scope| - # Assert Datadog context integrity - expect(current_trace_for(scope)).to_not be nil - end - end - - let(:older_datadog_span) { datadog_spans.first } - let(:younger_datadog_span) { datadog_spans.last } - - it { expect(datadog_spans).to have(2).items } - it { expect(older_datadog_span.name).to eq('operation.older_sibling') } - it { expect(older_datadog_span.parent_id).to eq(0) } - it { expect(older_datadog_span.finished?).to be true } - it { expect(younger_datadog_span.name).to eq('operation.younger_sibling') } - it { expect(younger_datadog_span.parent_id).to eq(0) } - it { expect(younger_datadog_span.finished?).to be true } - end - end -end diff --git a/spec/datadog/opentracer/tracer_spec.rb b/spec/datadog/opentracer/tracer_spec.rb deleted file mode 100644 index 3d0d5fde21c..00000000000 --- a/spec/datadog/opentracer/tracer_spec.rb +++ /dev/null @@ -1,222 +0,0 @@ -require 'spec_helper' - -require 'datadog/tracing/tracer' -require 'datadog/opentracer' - -RSpec.describe Datadog::OpenTracer::Tracer do - subject(:tracer) { described_class.new(writer: writer) } - - let(:writer) { FauxWriter.new } - - after { writer.stop } - - ### Datadog::OpenTracing::Tracer behavior ### - - describe '#initialize' do - context 'when given options' do - subject(:tracer) { described_class.new(**options) } - - let(:options) { { enabled: double } } - let(:datadog_tracer) { double('datadog_tracer') } - - before do - expect(Datadog::Tracing::Tracer).to receive(:new) - .with(**options) - .and_return(datadog_tracer) - end - - it { expect(tracer.datadog_tracer).to be(datadog_tracer) } - end - end - - describe '#datadog_tracer' do - subject(:datadog_tracer) { tracer.datadog_tracer } - - it { is_expected.to be_a_kind_of(Datadog::Tracing::Tracer) } - end - - ### Implemented OpenTracing::Tracer behavior ### - - describe '#scope_manager' do - subject(:scope_manager) { tracer.scope_manager } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::ThreadLocalScopeManager) } - end - - describe '#start_active_span' do - subject(:span) { tracer.start_active_span(name) } - - let(:name) { 'opentracing_span' } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::ThreadLocalScope) } - - context 'when a block is given' do - it do - expect { |b| tracer.start_active_span(name, &b) }.to yield_with_args( - a_kind_of(Datadog::OpenTracer::ThreadLocalScope) - ) - end - end - end - - describe '#start_span' do - subject(:span) { tracer.start_span(name) } - - let(:name) { 'opentracing_span' } - - it { is_expected.to be_a_kind_of(Datadog::OpenTracer::Span) } - end - - describe '#inject' do - subject(:inject) { tracer.inject(span_context, format, carrier) } - - let(:span_context) { instance_double(OpenTracing::SpanContext) } - let(:carrier) { instance_double(OpenTracing::Carrier) } - - shared_context 'by propagator' do - before do - expect(propagator).to receive(:inject) - .with(span_context, carrier) - end - end - - context 'when the format is' do - context 'OpenTracing::FORMAT_TEXT_MAP' do - include_context 'by propagator' - let(:format) { OpenTracing::FORMAT_TEXT_MAP } - let(:propagator) { Datadog::OpenTracer::TextMapPropagator } - - it { expect { inject }.to_not output.to_stdout } - it { is_expected.to be nil } - end - - context 'OpenTracing::FORMAT_BINARY' do - include_context 'by propagator' - let(:format) { OpenTracing::FORMAT_BINARY } - let(:propagator) { Datadog::OpenTracer::BinaryPropagator } - - it { expect { inject }.to_not output.to_stdout } - it { is_expected.to be nil } - end - - context 'OpenTracing::FORMAT_RACK' do - include_context 'by propagator' - let(:format) { OpenTracing::FORMAT_RACK } - let(:propagator) { Datadog::OpenTracer::RackPropagator } - - it { expect { inject }.to_not output.to_stdout } - it { is_expected.to be nil } - end - - context 'unknown' do - let(:format) { double('unknown format') } - - it { expect { inject }.to output(/Unknown inject format/).to_stderr } - end - end - end - - describe '#extract' do - subject(:extract) { tracer.extract(format, carrier) } - - let(:carrier) { instance_double(OpenTracing::Carrier) } - let(:span_context) { instance_double(Datadog::OpenTracer::SpanContext) } - - shared_context 'by propagator' do - before do - expect(propagator).to receive(:extract) - .with(carrier) - .and_return(span_context) - end - end - - context 'when the format is' do - context 'OpenTracing::FORMAT_TEXT_MAP' do - include_context 'by propagator' - let(:format) { OpenTracing::FORMAT_TEXT_MAP } - let(:propagator) { Datadog::OpenTracer::TextMapPropagator } - - it { expect { extract }.to_not output.to_stdout } - it { is_expected.to be span_context } - end - - context 'OpenTracing::FORMAT_BINARY' do - include_context 'by propagator' - let(:format) { OpenTracing::FORMAT_BINARY } - let(:propagator) { Datadog::OpenTracer::BinaryPropagator } - - it { expect { extract }.to_not output.to_stdout } - it { is_expected.to be span_context } - end - - context 'OpenTracing::FORMAT_RACK' do - include_context 'by propagator' - let(:format) { OpenTracing::FORMAT_RACK } - let(:propagator) { Datadog::OpenTracer::RackPropagator } - - it { expect { extract }.to_not output.to_stdout } - it { is_expected.to be span_context } - end - - context 'unknown' do - let(:format) { double('unknown format') } - - before { expect { extract }.to output(/Unknown extract format/).to_stderr } - - it { is_expected.to be nil } - end - end - end - - context 'after shutdown' do - subject(:shutdown!) { Datadog.shutdown! } - - before do - OpenTracing.global_tracer = described_class.new(writer: writer) - - Datadog.configure do |c| - # Do nothing - end - - shutdown! - end - - after do - Datadog.shutdown! - end - - context 'calling public apis' do - let(:tracer) do - OpenTracing.global_tracer - end - - it 'does not error on tracing' do - span = tracer.start_span('test') - - expect { span.finish }.to_not raise_error - end - - it 'does not error on tracing with block' do - scope = tracer.start_span('test') do |scp| - expect(scp).to be_a(OpenTracing::Scope) - end - - expect(scope).to be_a(OpenTracing::Span) - end - - it 'does not error on registered scope tracing' do - span = tracer.start_active_span('test') - - expect { span.close }.to_not raise_error - end - - it 'does not error on registered scope tracing with block' do - scope = tracer.start_active_span('test') do |scp| - expect(scp).to be_a(OpenTracing::Scope) - end - - expect(scope).to be_a(OpenTracing::Scope) - end - end - end -end diff --git a/vendor/rbs/opentracing/0/opentracing.rbs b/vendor/rbs/opentracing/0/opentracing.rbs deleted file mode 100644 index de8d1a1c50a..00000000000 --- a/vendor/rbs/opentracing/0/opentracing.rbs +++ /dev/null @@ -1,19 +0,0 @@ -module OpenTracing - class SpanContext - end - - class Carrier - end - - class Scope - end - - class Span - end - - class ScopeManager - end - - class Tracer - end -end