Class: ScoutApm::LayerConverters::RequestQueueTimeConverter
- Inherits:
-
ConverterBase
- Object
- ConverterBase
- ScoutApm::LayerConverters::RequestQueueTimeConverter
- Defined in:
- lib/scout_apm/layer_converters/request_queue_time_converter.rb
Constant Summary collapse
- HEADERS =
%w(X-Queue-Start X-Request-Start X-QUEUE-START X-REQUEST-START x-queue-start x-request-start)
Constants inherited from ConverterBase
Instance Attribute Summary
Attributes inherited from ConverterBase
#context, #layer_finder, #request, #root_layer
Instance Method Summary collapse
Methods inherited from ConverterBase
#attach_backtraces, #initialize, #limited?, #make_meta_options, #make_meta_options_desc_hash, #make_meta_options_scope, #over_metric_limit?, #register_hooks, #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 Method Details
#headers ⇒ Object
7 8 9 |
# File 'lib/scout_apm/layer_converters/request_queue_time_converter.rb', line 7 def headers request.headers end |
#record! ⇒ Object
11 12 13 14 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/request_queue_time_converter.rb', line 11 def record! return unless request.web? return unless context.config.value('record_queue_time') return unless headers # When an application uses Turbo Streams, we capture very innaccurate queue times. return if request_over_websocket? raw_start = return unless raw_start parsed_start = parse(raw_start) return unless parsed_start request_start = root_layer.start_time queue_time = (request_start - parsed_start).to_f # If we end up with a negative value, just bail out and don't report anything return if queue_time < 0 = MetricMeta.new("QueueTime/Request", {:scope => scope_layer.legacy_metric_name}) stat = MetricStats.new(true) stat.update!(queue_time) metrics = { => stat } @store.track!(metrics) metrics # this result must be returned so it can be accessed by transaction callback extensions end |