Sha256: c3148717ed57e00c91e3bda0d43b71f9d776e259f677a8f55e62e3db16a7b31c

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

require 'ddtrace/ext/manual_tracing'
require 'ddtrace/ext/priority'

module Datadog
  # Defines analytics behavior
  module ForcedTracing
    class << self
      def keep(span)
        return if span.nil? || span.context.nil?

        span.context.sampling_priority = Datadog::Ext::Priority::USER_KEEP
      end

      def drop(span)
        return if span.nil? || span.context.nil?

        span.context.sampling_priority = Datadog::Ext::Priority::USER_REJECT
      end
    end

    # Extension for Datadog::Span
    module Span
      def set_tag(key, value)
        # Configure sampling priority if they give us a forced tracing tag
        # DEV: Do not set if the value they give us is explicitly "false"
        case key
        when Ext::ManualTracing::TAG_KEEP
          ForcedTracing.keep(self) unless value == false
        when Ext::ManualTracing::TAG_DROP
          ForcedTracing.drop(self) unless value == false
        else
          # Otherwise, set the tag normally.
          super if defined?(super)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/forced_tracing.rb
ddtrace-0.51.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.50.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.49.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.48.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.47.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.46.0 lib/ddtrace/forced_tracing.rb