Class: MetricsAdapter::Trackers::SlowRequest
- Defined in:
- lib/metrics_adapter/trackers/slow_request.rb
Instance Attribute Summary collapse
-
#slow_request_threshold ⇒ Object
readonly
Returns the value of attribute slow_request_threshold.
Attributes inherited from Base
#adapter, #conditional, #event, #extra_attributes, #logger, #metric_name
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(event) ⇒ SlowRequest
constructor
A new instance of SlowRequest.
Constructor Details
#initialize(event) ⇒ SlowRequest
Returns a new instance of SlowRequest.
6 7 8 9 |
# File 'lib/metrics_adapter/trackers/slow_request.rb', line 6 def initialize(event) @slow_request_threshold = ::MetricsAdapter.thresholds.fetch(:slow_request) super end |
Instance Attribute Details
#slow_request_threshold ⇒ Object (readonly)
Returns the value of attribute slow_request_threshold.
4 5 6 |
# File 'lib/metrics_adapter/trackers/slow_request.rb', line 4 def slow_request_threshold @slow_request_threshold end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/metrics_adapter/trackers/slow_request.rb', line 11 def call return if conditional.present? && conditional.call.blank? if event.duration > slow_request_threshold data = { id: event.transaction_id, name: metric_name, duration: (event.duration / 1000), method: event.payload[:method].to_s.downcase, cpu_time_in_ms: event.cpu_time, idle_time_in_ms: event.idle_time, path: event.payload[:path] }.merge(extra_attributes) logger.info( "Slow request detected. Sending data to #{adapter.class.name}" ) if logger adapter.publish(data) end end |