Class: ScoutApm::LayerConverters::JobConverter
- Inherits:
-
ConverterBase
- Object
- ConverterBase
- ScoutApm::LayerConverters::JobConverter
- Defined in:
- lib/scout_apm/layer_converters/job_converter.rb
Constant Summary
Constants inherited from ConverterBase
Instance Attribute Summary collapse
-
#meta_options ⇒ Object
readonly
Returns the value of attribute meta_options.
Attributes inherited from ConverterBase
#context, #layer_finder, #request, #root_layer
Instance Method Summary collapse
-
#add_latency_metric! ⇒ Object
This isn’t stored as a specific layer, so grabbing it doesn’t use the walker callbacks.
- #record! ⇒ Object
- #register_hooks(walker) ⇒ Object
Methods inherited from ConverterBase
#attach_backtraces, #initialize, #limited?, #make_meta_options, #make_meta_options_desc_hash, #make_meta_options_scope, #over_metric_limit?, #scope_layer, #skip_layer?, #store_aggregate_metric, #store_backtrace, #store_specific_metric, #subscope_name, #subscoped?
Constructor Details
This class inherits a constructor from ScoutApm::LayerConverters::ConverterBase
Instance Attribute Details
#meta_options ⇒ Object (readonly)
Returns the value of attribute meta_options.
13 14 15 |
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 13 def @meta_options end |
Instance Method Details
#add_latency_metric! ⇒ Object
This isn’t stored as a specific layer, so grabbing it doesn’t use the walker callbacks
63 64 65 66 67 68 69 |
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 63 def add_latency_metric! latency = request.annotations[:queue_latency] || 0 = MetricMeta.new("Latency", ) stat = MetricStats.new stat.update!(latency) @metrics[] = stat end |
#record! ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 42 def record! return unless request.job? errors = request.error? ? 1 : 0 add_latency_metric! record = JobRecord.new( layer_finder.queue.name, layer_finder.job.name, layer_finder.job.total_call_time, layer_finder.job.total_exclusive_time, errors, @metrics ) @store.track_job!(record) record # this result must be returned so it can be accessed by transaction callback extensions end |
#register_hooks(walker) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/scout_apm/layer_converters/job_converter.rb', line 15 def register_hooks(walker) return unless request.job? super @metrics = Hash.new @meta_options = {:scope => layer_finder.job.legacy_metric_name} walker.on do |layer| next if layer == layer_finder.job next if layer == layer_finder.queue next if skip_layer?(layer) # we don't need to use the full metric name for scoped metrics as we # only display metrics aggregrated by type, just use "ActiveRecord" # or similar. metric_name = layer.type = MetricMeta.new(metric_name, ) @metrics[] ||= MetricStats.new( .has_key?(:scope) ) stat = @metrics[] stat.update!(layer.total_call_time, layer.total_exclusive_time) end end |