Class: ScoutApm::Serializers::JobsSerializerToJson

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/serializers/jobs_serializer_to_json.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jobs) ⇒ JobsSerializerToJson

Jobs is a pre-deduped/combined set of job records.



7
8
9
# File 'lib/scout_apm/serializers/jobs_serializer_to_json.rb', line 7

def initialize(jobs)
  @jobs = jobs
end

Instance Attribute Details

#jobsObject (readonly)

Returns the value of attribute jobs.



4
5
6
# File 'lib/scout_apm/serializers/jobs_serializer_to_json.rb', line 4

def jobs
  @jobs
end

Instance Method Details

#as_jsonObject

An array of job records



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scout_apm/serializers/jobs_serializer_to_json.rb', line 12

def as_json
  jobs.map do |job|
    {
      "queue" => job.queue_name,
      "name" => job.job_name,
      "count" => job.run_count,
      "errors" => job.errors,
      "total_time" => job.total_time.as_json,
      "exclusive_time" => job.exclusive_time.as_json,
      "metrics" => MetricsToJsonSerializer.new(job.metrics).as_json, # New style of metrics
    }
  end
end