pliny-librato 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +5 -4
- data/lib/pliny/librato/metrics/backend.rb +27 -22
- data/lib/pliny/librato/version.rb +1 -1
- 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: 5dad320432446a53b261cac33b5fc636eeb492c8
|
4
|
+
data.tar.gz: 234d35819926bb0ddb1b27be431478d2b7f43a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd225bebe9d5c1539da97b63072b33da4b1698946f4f75a4ac3dee9924951b957a23cd74185de160ad4abcb1d64d2f437cc58cc102076ed8d605a5f394c119b6
|
7
|
+
data.tar.gz: 4250c8362aa9d8e91e2aad1ba85f83193fe76453263baa3955942a7b0d83cf177918ea5f58f33489fa6aa68ef4f05bab7e473b1946ad71cf10bc9b4b1188c22e
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## Unreleased
|
8
|
+
|
9
|
+
## 0.5.1
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- The default submission interval is now 60 seconds for consistency with
|
14
|
+
l2met and this project's README.
|
15
|
+
- Metrics are now regularly submitted on the desired interval. Previously,
|
16
|
+
a new metric would need to be queued after the interval expired.
|
17
|
+
|
7
18
|
## 0.5.0
|
8
19
|
|
9
20
|
### Added
|
data/README.md
CHANGED
@@ -43,15 +43,16 @@ Pliny::Metrics.measure(:bar) do
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
-
By default, it will send queued metrics every minute,
|
47
|
-
queue reaches
|
46
|
+
By default, it will send queued metrics every minute, and anytime the
|
47
|
+
queue reaches 500 metrics. These settings can be configured on initialization.
|
48
48
|
|
49
49
|
## Shutdown
|
50
|
-
By default, any unsubmitted metrics on the queue will not be sent at shutdown.
|
50
|
+
By default, any unsubmitted metrics on the queue will not be sent at shutdown.
|
51
|
+
It is the responsibility of the caller to trigger this.
|
51
52
|
|
52
53
|
```ruby
|
53
54
|
# In the main process
|
54
|
-
|
55
|
+
Kernel.on_exit do
|
55
56
|
librato_backend.stop
|
56
57
|
end
|
57
58
|
|
@@ -9,7 +9,7 @@ module Pliny
|
|
9
9
|
class Backend
|
10
10
|
POISON_PILL = :'❨╯°□°❩╯︵┻━┻'
|
11
11
|
|
12
|
-
def initialize(source: nil, interval:
|
12
|
+
def initialize(source: nil, interval: 60, count: 500)
|
13
13
|
@source = source
|
14
14
|
@interval = interval
|
15
15
|
@count = count
|
@@ -24,61 +24,66 @@ module Pliny
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def start
|
27
|
-
|
27
|
+
start_counter
|
28
|
+
start_timer
|
28
29
|
self
|
29
30
|
end
|
30
31
|
|
31
32
|
def stop
|
32
33
|
metrics_queue.push(POISON_PILL)
|
33
|
-
|
34
|
+
timer.terminate
|
35
|
+
counter.join
|
36
|
+
flush_librato
|
34
37
|
end
|
35
38
|
|
36
39
|
private
|
37
40
|
|
38
|
-
attr_reader :source, :interval, :count, :
|
41
|
+
attr_reader :source, :interval, :count, :timer, :counter
|
39
42
|
|
40
|
-
def
|
41
|
-
@
|
43
|
+
def start_timer
|
44
|
+
@timer = Thread.new do
|
42
45
|
loop do
|
43
|
-
|
44
|
-
|
46
|
+
sleep interval
|
47
|
+
flush_librato
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
true
|
52
|
+
def start_counter
|
53
|
+
@counter = Thread.new do
|
54
|
+
loop do
|
55
|
+
msg = metrics_queue.pop
|
56
|
+
msg == POISON_PILL ? break : enqueue_librato(msg)
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
59
61
|
def enqueue_librato(msg)
|
60
|
-
|
62
|
+
sync { librato_queue.add(msg) }
|
61
63
|
end
|
62
64
|
|
63
65
|
def flush_librato
|
64
|
-
|
66
|
+
sync { librato_queue.submit }
|
65
67
|
end
|
66
68
|
|
67
|
-
def
|
68
|
-
|
69
|
+
def sync(&block)
|
70
|
+
mutex.synchronize(&block)
|
69
71
|
rescue => error
|
70
72
|
Pliny::ErrorReporters.notify(error)
|
71
73
|
end
|
72
74
|
|
75
|
+
def mutex
|
76
|
+
@mutex ||= Mutex.new
|
77
|
+
end
|
78
|
+
|
73
79
|
def metrics_queue
|
74
80
|
@metrics_queue ||= Queue.new
|
75
81
|
end
|
76
82
|
|
77
83
|
def librato_queue
|
78
84
|
@librato_queue ||= ::Librato::Metrics::Queue.new(
|
79
|
-
source:
|
80
|
-
|
81
|
-
autosubmit_count: count
|
85
|
+
source: source,
|
86
|
+
autosubmit_count: count
|
82
87
|
)
|
83
88
|
end
|
84
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny-librato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Appleton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-01-
|
12
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librato-metrics
|