Class: ScoutApm::LayerConverters::JobConverter
Instance Attribute Summary
#request, #root_layer, #walker
Instance Method Summary
collapse
#initialize, #scope_layer
Instance Method Details
#call ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 13
def call
return unless request.job?
JobRecord.new(
queue_layer.name,
job_layer.name,
job_layer.total_call_time,
job_layer.total_exclusive_time,
errors,
create_metrics
)
end
|
#create_metrics ⇒ Object
Full metrics from this request. These get aggregated in Store for the overview metrics, or stored permanently in a SlowTransaction Some merging of metrics will happen here, so if a request calls the same ActiveRecord or View repeatedly, it’ll get merged.
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 52
def create_metrics
metric_hash = Hash.new
meta_options = {:scope => job_layer.legacy_metric_name}
walker.walk do |layer|
next if layer == job_layer
next if layer == queue_layer
metric_name = layer.type
meta = MetricMeta.new(metric_name, meta_options)
metric_hash[meta] ||= MetricStats.new( meta_options.has_key?(:scope) )
stat = metric_hash[meta]
stat.update!(layer.total_call_time, layer.total_exclusive_time)
end
latency = request.annotations[:queue_latency] || 0
meta = MetricMeta.new("Latency", meta_options)
stat = MetricStats.new
stat.update!(latency)
metric_hash[meta] = stat
metric_hash
end
|
#errors ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 34
def errors
if request.error?
1
else
0
end
end
|
#find_first_layer_of_type(layer_type) ⇒ Object
42
43
44
45
46
|
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 42
def find_first_layer_of_type(layer_type)
walker.walk do |layer|
return layer if layer.type == layer_type
end
end
|
#job_layer ⇒ Object
30
31
32
|
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 30
def job_layer
@job_layer ||= find_first_layer_of_type("Job")
end
|
#queue_layer ⇒ Object
26
27
28
|
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 26
def queue_layer
@queue_layer ||= find_first_layer_of_type("Queue")
end
|