metriks 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/metriks.rb +1 -1
- data/lib/metriks/exponentially_decaying_sample.rb +5 -1
- data/metriks.gemspec +1 -1
- metadata +2 -2
data/lib/metriks.rb
CHANGED
@@ -38,7 +38,7 @@ module Metriks
|
|
38
38
|
|
39
39
|
def update(value, timestamp = Time.now)
|
40
40
|
@mutex.synchronize do
|
41
|
-
priority =
|
41
|
+
priority = weight(timestamp - @start_time) / rand
|
42
42
|
new_count = @count.update { |v| v + 1 }
|
43
43
|
if new_count <= @reservoir_size
|
44
44
|
@values[priority] = value
|
@@ -63,6 +63,10 @@ module Metriks
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
def weight(time)
|
67
|
+
Math.exp(@alpha * time)
|
68
|
+
end
|
69
|
+
|
66
70
|
def rescale(now, next_time)
|
67
71
|
if @next_scale_time.compare_and_swap(next_time, now + RESCALE_THRESHOLD)
|
68
72
|
@mutex.synchronize do
|
data/metriks.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'metriks'
|
16
|
-
s.version = '0.8.
|
16
|
+
s.version = '0.8.4'
|
17
17
|
s.date = '2012-02-27'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|