Sha256: 23a277331d8d14654ce1f9db62ff2e7a559ad836c6206f6c1bbcf38deab8ae86

Contents?: true

Size: 1.03 KB

Versions: 30

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

30 entries across 30 versions & 2 rubygems

Version Path
ddtrace-0.45.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.44.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.43.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.42.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.41.0 lib/ddtrace/forced_tracing.rb
ls-trace-0.2.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.40.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.39.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.38.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.37.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.36.0 lib/ddtrace/forced_tracing.rb
ls-trace-0.1.2 lib/ddtrace/forced_tracing.rb
ddtrace-0.35.2 lib/ddtrace/forced_tracing.rb
ddtrace-0.35.1 lib/ddtrace/forced_tracing.rb
ddtrace-0.35.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.34.2 lib/ddtrace/forced_tracing.rb
ddtrace-0.34.1 lib/ddtrace/forced_tracing.rb
ddtrace-0.34.0 lib/ddtrace/forced_tracing.rb
ddtrace-0.33.1 lib/ddtrace/forced_tracing.rb
ddtrace-0.33.0 lib/ddtrace/forced_tracing.rb