Sha256: 1130072d898a96fb27b407e7e83a6a6438f64a563dd4ea7aba3818b57f0d7e20

Contents?: true

Size: 820 Bytes

Versions: 13

Compression:

Stored size: 820 Bytes

Contents

require 'ddtrace/ext/analytics'

module Datadog
  # Defines analytics behavior
  module Analytics
    class << self
      def set_sample_rate(span, sample_rate)
        return if span.nil? || !sample_rate.is_a?(Numeric)
        span.set_metric(Datadog::Ext::Analytics::TAG_SAMPLE_RATE, sample_rate)
      end
    end

    # Extension for Datadog::Span
    module Span
      def set_tag(key, value)
        case key
        when Ext::Analytics::TAG_ENABLED
          # If true, set rate to 1.0, otherwise set 0.0.
          value = value == true ? Ext::Analytics::DEFAULT_SAMPLE_RATE : 0.0
          Analytics.set_sample_rate(self, value)
        when Ext::Analytics::TAG_SAMPLE_RATE
          Analytics.set_sample_rate(self, value)
        else
          super if defined?(super)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
ls-trace-0.1.2 lib/ddtrace/analytics.rb
ddtrace-0.33.1 lib/ddtrace/analytics.rb
ddtrace-0.33.0 lib/ddtrace/analytics.rb
ddtrace-0.32.0 lib/ddtrace/analytics.rb
ddtrace-0.31.1 lib/ddtrace/analytics.rb
ddtrace-0.31.0 lib/ddtrace/analytics.rb
ddtrace-0.30.1 lib/ddtrace/analytics.rb
ddtrace-0.30.0 lib/ddtrace/analytics.rb
ddtrace-0.29.1 lib/ddtrace/analytics.rb
ls-trace-0.1.1 lib/ddtrace/analytics.rb
ddtrace-0.29.0 lib/ddtrace/analytics.rb
ddtrace-0.28.0 lib/ddtrace/analytics.rb
ddtrace-0.27.0 lib/ddtrace/analytics.rb