Class: Contrast::Utils::Assess::SamplingUtil::RequestHistory
- Defined in:
- lib/contrast/utils/assess/sampling_util.rb
Overview
RequestHistory tracks one requests history per time window
Instance Attribute Summary collapse
-
#window_hit ⇒ Object
readonly
Returns the value of attribute window_hit.
-
#window_start ⇒ Object
readonly
Returns the value of attribute window_start.
Instance Method Summary collapse
- #elapsed ⇒ Object
- #hit(cnt = 1) ⇒ Object
-
#initialize ⇒ RequestHistory
constructor
A new instance of RequestHistory.
- #reset_window ⇒ Object
Constructor Details
#initialize ⇒ RequestHistory
Returns a new instance of RequestHistory.
65 66 67 68 |
# File 'lib/contrast/utils/assess/sampling_util.rb', line 65 def initialize @window_start = Contrast::Utils::Timer.now_ms @window_hit = 0 end |
Instance Attribute Details
#window_hit ⇒ Object (readonly)
Returns the value of attribute window_hit.
63 64 65 |
# File 'lib/contrast/utils/assess/sampling_util.rb', line 63 def window_hit @window_hit end |
#window_start ⇒ Object (readonly)
Returns the value of attribute window_start.
63 64 65 |
# File 'lib/contrast/utils/assess/sampling_util.rb', line 63 def window_start @window_start end |
Instance Method Details
#elapsed ⇒ Object
70 71 72 |
# File 'lib/contrast/utils/assess/sampling_util.rb', line 70 def elapsed Contrast::Utils::Timer.now_ms - window_start end |
#hit(cnt = 1) ⇒ Object
74 75 76 |
# File 'lib/contrast/utils/assess/sampling_util.rb', line 74 def hit cnt = 1 @window_hit += cnt end |