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
28
29
30
31
32
33
# 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,
      "mem_delta" => job.mem_delta,
      "allocations" => job.allocations,
      "seconds_since_startup" => job.seconds_since_startup,
      "hostname" => job.hostname,
      "git_sha" => job.git_sha,
      "metrics" => MetricsToJsonSerializer.new(job.metrics).as_json, # New style of metrics
      "allocation_metrics" => MetricsToJsonSerializer.new(job.allocation_metrics).as_json, # New style of metrics
      "context" => job.context.to_hash,
      "truncated_metrics" => job.truncated_metrics,

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