Class: CloudwatchQuery::Parsers::Rails::ActiveJobSubParser

Inherits:
Object
  • Object
show all
Includes:
SubParser
Defined in:
lib/cloudwatch_query/parsers/rails/sub_parsers.rb

Overview

Parses: "[ActiveJob] Enqueued JobClass (Job ID: uuid) to Sidekiq(queue)"

Constant Summary collapse

ACTIVE_JOB_REGEX =
/\[ActiveJob\]\s+Enqueued\s+(?<job_class>[\w:]+)\s+\(Job ID:\s+(?<job_id>[^)]+)\)\s+to\s+\w+\((?<queue>\w+)\)(?:\s+with arguments:\s+(?<arguments>.+))?$/

Class Method Summary collapse

Methods included from SubParser

included

Class Method Details

.matches?(message) ⇒ Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/cloudwatch_query/parsers/rails/sub_parsers.rb', line 109

def self.matches?(message)
  message.include?("[ActiveJob] Enqueued")
end

.parse(message, _base_data) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/cloudwatch_query/parsers/rails/sub_parsers.rb', line 113

def self.parse(message, _base_data)
  match = message.match(ACTIVE_JOB_REGEX)
  return {} unless match

  {
    line_type: :active_job,
    job_class: match[:job_class],
    job_id: match[:job_id],
    queue: match[:queue],
    arguments: match[:arguments]&.strip
  }
end