Sha256: b602f4c8c2c12dd9da2c6cd9e5b74ef74f8978dbcad79594d9d15c3b7c9c8e79

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module Datadog
  module Tracing
    module Pipeline
      # This processor executes the configured `operation` for each {Datadog::Tracing::Span}
      # in a {Datadog::Tracing::TraceSegment}.
      #
      # @public_api
      class SpanProcessor
        # You can either provide an `operation` object or a block to this method.
        #
        # Both have the same semantics as `operation`.
        # `operation` is used if both `operation` and a block are present.
        #
        # @param [#call(Datadog::Tracing::Span)] operation a callable that can modify the span.
        def initialize(operation = nil, &block)
          callable = operation || block

          raise(ArgumentError) unless callable.respond_to?(:call)

          @operation = operation || block
        end

        # Invokes `operation#call` for each spans in the `trace` argument.
        # @param [Datadog::Tracing::TraceSegment] trace a trace segment.
        # @return [Datadog::Tracing::TraceSegment] the `trace` provided as an argument.
        # @!visibility private
        def call(trace)
          trace.spans.each do |span|
            @operation.call(span) rescue next
          end

          trace
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-1.10.1 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.10.0 lib/datadog/tracing/pipeline/span_processor.rb