librato-rails 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/librato/rails/aggregator.rb +18 -15
- data/lib/librato/rails/version.rb +1 -1
- data/lib/librato/rails.rb +0 -1
- data/test/dummy/log/test.log +119 -4995
- data/test/integration/{helper_test.rb → custom_test.rb} +11 -11
- metadata +5 -48
- data/lib/librato/rails/helpers.rb +0 -19
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -2189
- data/test/dummy/test_env.sh +0 -2
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CDF/870/sprockets%2Fb878faf942403e313a5b103e5d80488e +0 -0
- data/test/dummy/tmp/cache/assets/CE8/7E0/sprockets%2F178e2a1f9aa891d473009c7f3095df28 +0 -0
- data/test/dummy/tmp/cache/assets/CF9/7C0/sprockets%2F40fc2f3d2a468a00e463f1d313cb1683 +0 -0
- data/test/dummy/tmp/cache/assets/D04/890/sprockets%2F587335c079eef8d5a63784fc8f99905a +0 -0
- data/test/dummy/tmp/cache/assets/D05/D40/sprockets%2F1c9faaf28d05409b88ad3113374d613c +0 -0
- data/test/dummy/tmp/cache/assets/D11/D90/sprockets%2Ff688bee5b15ad322749fd06432065df2 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D48/6E0/sprockets%2F3d5dd928c45756c99bb1018cdbba7485 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D4F/000/sprockets%2F25e44896aac12384727e9dab827ebef9 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D66/890/sprockets%2F789354d3ec91e1ba6c8e92878d8f6ff8 +0 -0
- data/test/dummy/tmp/cache/assets/D84/000/sprockets%2F2ed60caa8412eb8334fe327cab12cb32 +0 -0
- data/test/dummy/tmp/cache/assets/D8B/F90/sprockets%2Ffe6ce696e9141eb755d8eed79128e17c +0 -0
- data/test/dummy/tmp/cache/assets/D98/8B0/sprockets%2Fedbef6e0d0a4742346cf479f2c522eb0 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
@@ -2,14 +2,14 @@ module Librato
|
|
2
2
|
module Rails
|
3
3
|
class Aggregator
|
4
4
|
extend Forwardable
|
5
|
-
|
5
|
+
|
6
6
|
def_delegators :@cache, :empty?
|
7
|
-
|
7
|
+
|
8
8
|
def initialize
|
9
9
|
@cache = Librato::Metrics::Aggregator.new
|
10
10
|
@lock = Mutex.new
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def [](key)
|
14
14
|
return nil if @cache.empty?
|
15
15
|
gauges = nil
|
@@ -19,12 +19,12 @@ module Librato
|
|
19
19
|
end
|
20
20
|
nil
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def delete_all
|
24
24
|
@lock.synchronize { @cache.clear }
|
25
25
|
end
|
26
|
-
|
27
|
-
# transfer all measurements to a queue and
|
26
|
+
|
27
|
+
# transfer all measurements to a queue and
|
28
28
|
# reset internal status
|
29
29
|
def flush_to(queue, options={})
|
30
30
|
queued = nil
|
@@ -35,23 +35,26 @@ module Librato
|
|
35
35
|
end
|
36
36
|
queue.merge!(queued) if queued
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def measure(*args, &block)
|
40
40
|
event = args[0].to_s
|
41
41
|
returned = nil
|
42
|
+
if block_given?
|
43
|
+
start = Time.now
|
44
|
+
returned = yield
|
45
|
+
value = ((Time.now - start) * 1000.0).to_i
|
46
|
+
elsif args[1]
|
47
|
+
value = args[1]
|
48
|
+
else
|
49
|
+
raise "no value provided"
|
50
|
+
end
|
42
51
|
@lock.synchronize do
|
43
|
-
|
44
|
-
start = Time.now
|
45
|
-
returned = yield
|
46
|
-
@cache.add event => ((Time.now - start) * 1000.0).to_i
|
47
|
-
else
|
48
|
-
@cache.add event => args[1] || nil
|
49
|
-
end
|
52
|
+
@cache.add event => value
|
50
53
|
end
|
51
54
|
returned
|
52
55
|
end
|
53
56
|
alias :timing :measure
|
54
|
-
|
57
|
+
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
data/lib/librato/rails.rb
CHANGED