cabin 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cabin/metrics/timer.rb +2 -1
- data/test/test_metrics.rb +13 -0
- metadata +15 -15
data/lib/cabin/metrics/timer.rb
CHANGED
@@ -14,7 +14,8 @@ class Cabin::Metrics::Timer < Cabin::Metrics::Histogram
|
|
14
14
|
return time_block(&block) if block_given?
|
15
15
|
|
16
16
|
# Return an object we can .stop
|
17
|
-
|
17
|
+
# Call record(...) when we stop.
|
18
|
+
return TimerContext.new { |duration| record(duration) }
|
18
19
|
end # def time
|
19
20
|
|
20
21
|
private
|
data/test/test_metrics.rb
CHANGED
@@ -56,6 +56,19 @@ describe Cabin::Metrics do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
test "timer.time without block" do
|
60
|
+
timer = @metrics.timer(self)
|
61
|
+
30.times do |i|
|
62
|
+
assert_equal(i, timer.value)
|
63
|
+
assert_equal(i, timer.to_hash[:count])
|
64
|
+
t = timer.time
|
65
|
+
t.stop
|
66
|
+
assert(timer.to_hash[:total] > 0, "total should be nonzero")
|
67
|
+
assert(timer.to_hash[:mean] > 0, "mean should be nonzero")
|
68
|
+
assert(timer.to_hash[:max] > 0, "max should be nonzero")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
59
72
|
test "metrics from Cabin::Metrics" do
|
60
73
|
# Verify the Metrics api for creating new metrics.
|
61
74
|
metrics = Cabin::Metrics.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cabin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &15416680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15416680
|
25
25
|
description: This is an experiment to try and make logging more flexible and more
|
26
26
|
consumable. Plain text logs are bullshit, let's emit structured and contextual logs.
|
27
27
|
Metrics, too!
|
@@ -32,28 +32,28 @@ executables:
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- lib/cabin.rb
|
36
|
-
- lib/cabin/
|
35
|
+
- lib/cabin/inspectable.rb
|
36
|
+
- lib/cabin/context.rb
|
37
|
+
- lib/cabin/timer.rb
|
37
38
|
- lib/cabin/outputs/stdlib-logger.rb
|
38
|
-
- lib/cabin/
|
39
|
+
- lib/cabin/outputs/em/stdlib-logger.rb
|
40
|
+
- lib/cabin/mixins/logger.rb
|
41
|
+
- lib/cabin/mixins/dragons.rb
|
42
|
+
- lib/cabin/mixins/CAPSLOCK.rb
|
39
43
|
- lib/cabin/namespace.rb
|
40
|
-
- lib/cabin/metrics/counter.rb
|
41
|
-
- lib/cabin/metrics/timer.rb
|
42
44
|
- lib/cabin/metrics/gauge.rb
|
43
45
|
- lib/cabin/metrics/histogram.rb
|
46
|
+
- lib/cabin/metrics/timer.rb
|
44
47
|
- lib/cabin/metrics/meter.rb
|
45
|
-
- lib/cabin/
|
46
|
-
- lib/cabin/timer.rb
|
48
|
+
- lib/cabin/metrics/counter.rb
|
47
49
|
- lib/cabin/metrics.rb
|
48
|
-
- lib/cabin/
|
49
|
-
- lib/cabin
|
50
|
-
- lib/cabin/mixins/CAPSLOCK.rb
|
51
|
-
- lib/cabin/mixins/logger.rb
|
50
|
+
- lib/cabin/channel.rb
|
51
|
+
- lib/cabin.rb
|
52
52
|
- examples/fibonacci-timing.rb
|
53
53
|
- examples/sinatra-logging.rb
|
54
54
|
- examples/sample.rb
|
55
|
-
- test/minitest-patch.rb
|
56
55
|
- test/test_logging.rb
|
56
|
+
- test/minitest-patch.rb
|
57
57
|
- test/test_metrics.rb
|
58
58
|
- test/all.rb
|
59
59
|
- LICENSE
|