Sha256: 1ea58dbc6cb36d120ebfda8be1932bd987d5a47d9e05b03e6c62c40c05b76c33
Contents?: true
Size: 989 Bytes
Versions: 7
Compression:
Stored size: 989 Bytes
Contents
module Datadog module Pipeline # SpanFilter implements a processor that filters entire span subtrees class SpanFilter def initialize(filter = nil, &block) callable = filter || block raise(ArgumentError) unless callable.respond_to?(:call) @criteria = filter || block end # 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. 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 def drop_it?(span) @criteria.call(span) rescue false end end end end
Version data entries
7 entries across 7 versions & 1 rubygems