diff options
author | Sean McGivern <sean@gitlab.com> | 2019-08-06 18:04:43 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-08-28 18:39:33 +0300 |
commit | 23c1cfcc110b52c1060f35a4a4a7816fb38adc6c (patch) | |
tree | ac75fd2c875e0aa487cba99b0db8bbea94078826 /lib/peek/views/active_record.rb | |
parent | 7671c592f826f44be5a8a7dc947fba467f5df851 (diff) |
Return warnings for performance bar from backend
For each DetailedView subclass, we add a `warnings` array to:
1. The top-level response.
2. Each individual call under the `details` key.
We use the `.thresholds` hash on the DetailedView to determine what's a
warning. If that hash is empty (the default), then the warnings array
will always be empty.
Diffstat (limited to 'lib/peek/views/active_record.rb')
-rw-r--r-- | lib/peek/views/active_record.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/peek/views/active_record.rb b/lib/peek/views/active_record.rb index 2d78818630d..a35783c1971 100644 --- a/lib/peek/views/active_record.rb +++ b/lib/peek/views/active_record.rb @@ -3,6 +3,24 @@ module Peek module Views class ActiveRecord < DetailedView + DEFAULT_THRESHOLDS = { + calls: 100, + duration: 3, + individual_call: 1 + }.freeze + + THRESHOLDS = { + production: { + calls: 100, + duration: 15, + individual_call: 5 + } + }.freeze + + def self.thresholds + @thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS) + end + private def setup_subscribers |