Class: Lapsoss::ExclusionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/lapsoss/exclusion_filter.rb

Overview

Error exclusion system for filtering exception types

Instance Method Summary collapse

Constructor Details

#initialize(configuration = {}) ⇒ ExclusionFilter

Returns a new instance of ExclusionFilter.



6
7
8
9
10
11
12
13
# File 'lib/lapsoss/exclusion_filter.rb', line 6

def initialize(configuration = {})
  @excluded_exceptions = configuration[:excluded_exceptions] || []
  @excluded_patterns = configuration[:excluded_patterns] || []
  @excluded_messages = configuration[:excluded_messages] || []
  @excluded_environments = configuration[:excluded_environments] || []
  @custom_filters = configuration[:custom_filters] || []
  @inclusion_overrides = configuration[:inclusion_overrides] || []
end

Instance Method Details

#add_exclusion(type, value) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lapsoss/exclusion_filter.rb', line 29

def add_exclusion(type, value)
  case type
  when :exception
    @excluded_exceptions << value
  when :pattern
    @excluded_patterns << value
  when :message
    @excluded_messages << value
  when :environment
    @excluded_environments << value
  when :custom
    @custom_filters << value
  else
    raise ArgumentError, "Unknown exclusion type: #{type}"
  end
end

#add_inclusion_override(filter) ⇒ Object



46
47
48
# File 'lib/lapsoss/exclusion_filter.rb', line 46

def add_inclusion_override(filter)
  @inclusion_overrides << filter
end

#clear_exclusions(type = nil) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/lapsoss/exclusion_filter.rb', line 50

def clear_exclusions(type = nil)
  if type
    case type
    when :exception then @excluded_exceptions.clear
    when :pattern then @excluded_patterns.clear
    when :message then @excluded_messages.clear
    when :environment then @excluded_environments.clear
    when :custom then @custom_filters.clear
    else raise ArgumentError, "Unknown exclusion type: #{type}"
    end
  else
    @excluded_exceptions.clear
    @excluded_patterns.clear
    @excluded_messages.clear
    @excluded_environments.clear
    @custom_filters.clear
  end
end

#exclusion_statsObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/lapsoss/exclusion_filter.rb', line 69

def exclusion_stats
  {
    excluded_exceptions: @excluded_exceptions.length,
    excluded_patterns: @excluded_patterns.length,
    excluded_messages: @excluded_messages.length,
    excluded_environments: @excluded_environments.length,
    custom_filters: @custom_filters.length,
    inclusion_overrides: @inclusion_overrides.length
  }
end

#should_exclude?(event) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lapsoss/exclusion_filter.rb', line 15

def should_exclude?(event)
  # Check inclusion overrides first - these take precedence
  return false if should_include_override?(event)

  # Apply exclusion filters
  return true if excluded_by_exception_type?(event)
  return true if excluded_by_pattern?(event)
  return true if excluded_by_message?(event)
  return true if excluded_by_environment?(event)
  return true if excluded_by_custom_filter?(event)

  false
end