Sha256: 27118eb84291165e4e6de8c776611597e3318a15956b75c363b3a73e437b4f50

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

# typed: true

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

16 entries across 16 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.8.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.7.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.6.1 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.6.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.5.2 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.5.1 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.5.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.4.2 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.4.1 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.4.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.3.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.2.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.1.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.0.0 lib/datadog/tracing/pipeline/span_processor.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/pipeline/span_processor.rb