class Datadog::Pipeline::SpanFilter
SpanFilter
implements a processor that filters entire span subtrees
Public Class Methods
new(filter = nil, &block)
click to toggle source
# File lib/ddtrace/pipeline/span_filter.rb, line 6 def initialize(filter = nil, &block) callable = filter || block raise(ArgumentError) unless callable.respond_to?(:call) @criteria = filter || block end
Public Instance Methods
call(trace)
click to toggle source
NOTE: this SpanFilter
implementation only handles traces in which child spans appear after parent spans in the trace array. If in the future child spans can be before parent spans, then the code below will need to be updated.
# File lib/ddtrace/pipeline/span_filter.rb, line 17 def call(trace) deleted = Set.new trace.delete_if do |span| if deleted.include?(span.parent) deleted << span true else drop = drop_it?(span) deleted << span if drop drop end end end
Private Instance Methods
drop_it?(span)
click to toggle source
# File lib/ddtrace/pipeline/span_filter.rb, line 34 def drop_it?(span) @criteria.call(span) rescue false end