Class: Contrast::Utils::Assess::SamplingUtil::RequestHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/utils/assess/sampling_util.rb

Overview

RequestHistory tracks one requests history per time window

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRequestHistory

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_hitObject (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_startObject (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

#elapsedObject



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

#reset_windowObject



78
79
80
81
# File 'lib/contrast/utils/assess/sampling_util.rb', line 78

def reset_window
  @window_start = Contrast::Utils::Timer.now_ms
  @window_hit = 0
end