Class: Instana::SpanFiltering::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/span_filtering/condition.rb

Overview

Represents a condition for filtering spans

A condition consists of:

  • key: The attribute to match against (category, kind, type, or span attribute)

  • values: List of values to match against (OR logic between values)

  • match_type: String matching strategy (strict, startswith, endswith, contains)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, values, match_type = 'strict') ⇒ Condition

Returns a new instance of Condition.



14
15
16
17
18
# File 'lib/instana/span_filtering/condition.rb', line 14

def initialize(key, values, match_type = 'strict')
  @key = key
  @values = Array(values)
  @match_type = match_type
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



12
13
14
# File 'lib/instana/span_filtering/condition.rb', line 12

def key
  @key
end

#match_typeObject (readonly)

Returns the value of attribute match_type.



12
13
14
# File 'lib/instana/span_filtering/condition.rb', line 12

def match_type
  @match_type
end

#valuesObject (readonly)

Returns the value of attribute values.



12
13
14
# File 'lib/instana/span_filtering/condition.rb', line 12

def values
  @values
end

Instance Method Details

#matches?(span) ⇒ Boolean

Check if a span matches this condition

Parameters:

  • span (Hash)

    The span to check

Returns:

  • (Boolean)

    True if the span matches any of the values



23
24
25
26
27
28
# File 'lib/instana/span_filtering/condition.rb', line 23

def matches?(span)
  attribute_value = extract_attribute(span, @key)
  return false if attribute_value.nil?

  @values.any? { |value| matches_value?(attribute_value, value) }
end