pliny 0.20.0 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pliny/metrics.rb +16 -4
- data/lib/pliny/utils.rb +2 -0
- data/lib/pliny/version.rb +1 -1
- data/lib/template/lib/initializer.rb +1 -1
- data/spec/metrics_spec.rb +25 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1424dc0c288ffda2c41014a5be8021194146f328
|
4
|
+
data.tar.gz: 238fb1ae442b1392ebd61ffeea5c966501613c13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66625177b344dbf1074856e7ef2a220df87ace5142608e83898641b6831ae8f6c57f0b9e456317483a2b971331ce349c20e092cec2cafd94170dbe0edf1a9b48
|
7
|
+
data.tar.gz: 56eb5cd7378f88adc4750dea565ccb373ea4f9594cd25eac2eb9a3035c4538efdb3b1974239c864ac17049c71bce468a82c1764a68c8b7689e34167d6805ab1a
|
data/lib/pliny/metrics.rb
CHANGED
@@ -16,15 +16,27 @@ module Pliny
|
|
16
16
|
counts
|
17
17
|
end
|
18
18
|
|
19
|
-
def measure(*names, &block)
|
20
|
-
|
21
|
-
|
19
|
+
def measure(*names, **opts, &block)
|
20
|
+
if block
|
21
|
+
elapsed, return_value = time_elapsed(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
measurement =
|
25
|
+
if opts.has_key?(:value)
|
26
|
+
opts[:value]
|
27
|
+
elsif block
|
28
|
+
elapsed
|
29
|
+
else
|
30
|
+
0
|
31
|
+
end
|
32
|
+
|
33
|
+
measures = Hash[names.map { |n| ["#{Config.app_name}.#{n}", measurement] }]
|
22
34
|
|
23
35
|
backends.each do |backend|
|
24
36
|
report_and_catch { backend.report_measures(measures) }
|
25
37
|
end
|
26
38
|
|
27
|
-
return_value
|
39
|
+
block ? return_value : measures
|
28
40
|
end
|
29
41
|
|
30
42
|
private
|
data/lib/pliny/utils.rb
CHANGED
data/lib/pliny/version.rb
CHANGED
data/spec/metrics_spec.rb
CHANGED
@@ -52,14 +52,14 @@ describe Pliny::Metrics do
|
|
52
52
|
Pliny::Metrics.backends = [test_backend]
|
53
53
|
end
|
54
54
|
|
55
|
-
it "measures a single key" do
|
55
|
+
it "measures a block's execution time with a single key" do
|
56
56
|
metrics.measure(:foo) { }
|
57
57
|
expect(test_backend).to have_received(:report_measures).once.with(
|
58
58
|
"pliny.foo" => 0
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
-
it "measures a
|
62
|
+
it "measures a long block's execution time with a single key" do
|
63
63
|
metrics.measure(:foo) do
|
64
64
|
Timecop.travel(60)
|
65
65
|
end
|
@@ -69,12 +69,34 @@ describe Pliny::Metrics do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
it "measures multiple keys" do
|
72
|
+
it "measures a block's execution time with multiple keys" do
|
73
73
|
metrics.measure(:foo, :bar) { }
|
74
74
|
expect(test_backend).to have_received(:report_measures).once.with(
|
75
75
|
"pliny.foo" => 0,
|
76
76
|
"pliny.bar" => 0
|
77
77
|
)
|
78
78
|
end
|
79
|
+
|
80
|
+
it "measures a given value for a single key without a block" do
|
81
|
+
metrics.measure(:baz, value: 3.14)
|
82
|
+
expect(test_backend).to have_received(:report_measures).once.with(
|
83
|
+
"pliny.baz" => 3.14
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "measures a given value for multiple keys with a block" do
|
88
|
+
metrics.measure(:qux, :corge, value: 42) { }
|
89
|
+
expect(test_backend).to have_received(:report_measures).once.with(
|
90
|
+
"pliny.qux" => 42,
|
91
|
+
"pliny.corge" => 42
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "measures a value of 0 when no key or block is provided" do
|
96
|
+
metrics.measure(:waldo)
|
97
|
+
expect(test_backend).to have_received(:report_measures).once.with(
|
98
|
+
"pliny.waldo" => 0
|
99
|
+
)
|
100
|
+
end
|
79
101
|
end
|
80
102
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur Leach
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-12-
|
12
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|