Class: ScoutApm::Serializers::SlowJobsSerializerToJson

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jobs) ⇒ SlowJobsSerializerToJson

Jobs is a series of slow job records



7
8
9
# File 'lib/scout_apm/serializers/slow_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/slow_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
25
26
27
# File 'lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb', line 12

def as_json
  jobs.map do |job|
    {
      "queue" => job.queue_name,
      "name" => job.job_name,
      "time" => job.time,
      "total_time" => job.total_time,
      "exclusive_time" => job.exclusive_time,

      "metrics" => MetricsToJsonSerializer.new(job.metrics).as_json, # New style of metrics
      "context" => job.context.to_hash,

      "score" => job.score,
    }
  end
end