Class: CloudwatchQuery::Parsers::SidekiqParser
- Defined in:
- lib/cloudwatch_query/parsers/sidekiq_parser.rb
Constant Summary collapse
- BUILT_IN_SUB_PARSERS =
Built-in sub-parsers mapped to symbols
{ start: Sidekiq::StartSubParser, done: Sidekiq::DoneSubParser, fail: Sidekiq::FailSubParser }.freeze
- SIDEKIQ_PATTERN =
Matches Sidekiq log format: "2026-02-04T20:46:15.201Z pid=123 tid=abc class=Job jid=xyz"
/^\d{4}-\d{2}-\d{2}T[\d:.]+Z\s+pid=\d+\s+tid=\w+\s+class=/- BASE_REGEX =
/^(?<timestamp>\d{4}-\d{2}-\d{2}T[\d:.]+Z)\s+pid=(?<pid>\d+)\s+tid=(?<tid>\w+)\s+class=(?<job_class>[\w:]+)\s+jid=(?<jid>\w+)/
Instance Attribute Summary collapse
-
#sub_parsers ⇒ Object
readonly
Returns the value of attribute sub_parsers.
Class Method Summary collapse
-
.available_sub_parsers ⇒ Object
List available built-in sub-parser names.
- .matches?(message) ⇒ Boolean
- .parse(message) ⇒ Object
- .parser_name ⇒ Object
Instance Method Summary collapse
-
#initialize(*args) ⇒ SidekiqParser
constructor
Initialize with specific sub-parsers or use all defaults.
- #matches?(message) ⇒ Boolean
- #parse(message) ⇒ Object
Constructor Details
#initialize(*args) ⇒ SidekiqParser
Initialize with specific sub-parsers or use all defaults
36 37 38 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 36 def initialize(*args) @sub_parsers = resolve_sub_parsers(args) end |
Instance Attribute Details
#sub_parsers ⇒ Object (readonly)
Returns the value of attribute sub_parsers.
20 21 22 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 20 def sub_parsers @sub_parsers end |
Class Method Details
.available_sub_parsers ⇒ Object
List available built-in sub-parser names
81 82 83 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 81 def available_sub_parsers BUILT_IN_SUB_PARSERS.keys end |
.matches?(message) ⇒ Boolean
68 69 70 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 68 def matches?() new.matches?() end |
.parse(message) ⇒ Object
72 73 74 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 72 def parse() new.parse() end |
.parser_name ⇒ Object
76 77 78 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 76 def parser_name "sidekiq" end |
Instance Method Details
#matches?(message) ⇒ Boolean
40 41 42 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 40 def matches?() .match?(SIDEKIQ_PATTERN) end |
#parse(message) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cloudwatch_query/parsers/sidekiq_parser.rb', line 44 def parse() return nil unless matches?() base_data = extract_base_data() return nil if base_data.empty? # Try each sub-parser until one matches sub_parser_data = {} @sub_parsers.each do |parser| if parser.matches?() sub_parser_data = parser.parse(, base_data) break if sub_parser_data[:line_type] end end # If no sub-parser matched, mark as unknown sub_parser_data[:line_type] ||= :unknown sub_parser_data[:raw_message] = if sub_parser_data[:line_type] == :unknown Sidekiq::SidekiqLog.new(base_data.merge(sub_parser_data)) end |