pliny-librato 0.5.2 → 0.6.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +11 -7
- data/lib/pliny/librato/metrics/backend.rb +21 -26
- data/lib/pliny/librato/version.rb +1 -1
- data/pliny-librato.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d432f6b4a5b01f98e0ead542ae5e43c15823852d
|
4
|
+
data.tar.gz: d73cfb2d9a49fe63e6c71baa56385419a51d9464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fafc04571c053f2eb05cbfe0baba3e38ef698ecc6eacf0c516c6f7ec4d2adfc483e3243e1a76e55c7d147078fe6296cf50c0310c6c1daff18f1e7e4cc3cf6ebb
|
7
|
+
data.tar.gz: da313c6aa6c543af1921714b3c54839f12125741caabbb57b6826eb4e6a7e54a58c447615801d3e5071c01431beb6dbede6b8f5ab91d995122af35b3b31715e3
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
7
7
|
## Unreleased
|
8
8
|
|
9
|
+
## 0.6.0
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- `Aggregator` and `CounterCache` from `librato-rack` are now leveraged
|
14
|
+
to reduce the number of metrics submitted for a given flush. This will
|
15
|
+
reduce the total number of measurements submitted, and have a much lower
|
16
|
+
impact on Librato's rate limiting.
|
17
|
+
|
18
|
+
### Removed
|
19
|
+
|
20
|
+
- `count` is no longer supported as an initialization option. The queue is
|
21
|
+
only flushed based on the provided `interval`, or by calling `#stop`.
|
22
|
+
|
9
23
|
## 0.5.2
|
10
24
|
|
11
25
|
### Fixed
|
data/README.md
CHANGED
@@ -24,13 +24,18 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
|
27
|
+
Update (or add) your metrics initializer `config/initializers/metrics.rb` with:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
if Config.librato_email && Config.librato_key
|
31
|
+
Librato::Metrics.authenticate(Config.librato_email, Config.librato_key)
|
32
|
+
Pliny::Metrics.backends = [Pliny::Librato::Metrics::Backend.new(
|
33
|
+
source: "#{Config.app_name}.#{Config.app_env}",
|
34
|
+
interval: 30
|
35
|
+
).tap(&:start)]
|
36
|
+
else
|
37
|
+
Pliny::Metrics.backends = [Pliny::Metrics::Backends::Logger]
|
38
|
+
end
|
34
39
|
```
|
35
40
|
|
36
41
|
Now `Pliny::Metrics` methods will build a queue and automatically send metrics
|
@@ -43,8 +48,7 @@ Pliny::Metrics.measure(:bar) do
|
|
43
48
|
end
|
44
49
|
```
|
45
50
|
|
46
|
-
By default, it will send queued metrics every minute,
|
47
|
-
queue reaches 500 metrics. These settings can be configured on initialization.
|
51
|
+
By default, it will send queued metrics every minute, but can be configured on initialization.
|
48
52
|
|
49
53
|
## Shutdown
|
50
54
|
By default, any unsubmitted metrics on the queue will not be sent at shutdown.
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'librato/metrics'
|
2
2
|
require 'pliny/error_reporters'
|
3
|
+
require 'librato/collector'
|
3
4
|
|
4
5
|
module Pliny
|
5
6
|
module Librato
|
@@ -7,43 +8,45 @@ module Pliny
|
|
7
8
|
# Implements the Pliny::Metrics.backends API. Puts any metrics sent
|
8
9
|
# from Pliny::Metrics onto a queue that gets submitted in batches.
|
9
10
|
class Backend
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(source: nil, interval: 60, count: 500)
|
11
|
+
def initialize(source: nil, interval: 60)
|
13
12
|
@interval = interval
|
14
13
|
@mutex = Mutex.new
|
15
|
-
@
|
14
|
+
@counter_cache = ::Librato::Collector::CounterCache.new(default_tags: nil)
|
15
|
+
@aggregator = ::Librato::Metrics::Aggregator.new
|
16
16
|
@librato_queue = ::Librato::Metrics::Queue.new(
|
17
|
-
source:
|
18
|
-
|
17
|
+
source: source,
|
18
|
+
skip_measurement_times: true
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
22
22
|
def report_counts(counts)
|
23
|
-
|
23
|
+
sync do
|
24
|
+
counts.each do |name, val|
|
25
|
+
counter_cache.increment(name, val)
|
26
|
+
end
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def report_measures(measures)
|
27
|
-
|
31
|
+
sync do
|
32
|
+
aggregator.add(measures)
|
33
|
+
end
|
28
34
|
end
|
29
35
|
|
30
36
|
def start
|
31
|
-
start_counter
|
32
37
|
start_timer
|
33
38
|
self
|
34
39
|
end
|
35
40
|
|
36
41
|
def stop
|
37
|
-
metrics_queue.push(POISON_PILL)
|
38
42
|
# Ensure timer is not running when we terminate it
|
39
43
|
sync { timer.terminate }
|
40
|
-
counter.join
|
41
44
|
flush_librato
|
42
45
|
end
|
43
46
|
|
44
47
|
private
|
45
48
|
|
46
|
-
attr_reader :interval, :timer, :
|
49
|
+
attr_reader :interval, :timer, :counter_cache, :aggregator, :librato_queue
|
47
50
|
|
48
51
|
def start_timer
|
49
52
|
@timer = Thread.new do
|
@@ -54,21 +57,13 @@ module Pliny
|
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
|
-
def start_counter
|
58
|
-
@counter = Thread.new do
|
59
|
-
loop do
|
60
|
-
msg = metrics_queue.pop
|
61
|
-
msg == POISON_PILL ? break : enqueue_librato(msg)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def enqueue_librato(msg)
|
67
|
-
sync { librato_queue.add(msg) }
|
68
|
-
end
|
69
|
-
|
70
60
|
def flush_librato
|
71
|
-
sync
|
61
|
+
sync do
|
62
|
+
counter_cache.flush_to(librato_queue)
|
63
|
+
librato_queue.merge!(aggregator)
|
64
|
+
aggregator.clear
|
65
|
+
end
|
66
|
+
librato_queue.submit
|
72
67
|
end
|
73
68
|
|
74
69
|
def sync(&block)
|
data/pliny-librato.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency 'librato-metrics', '~> 2.0'
|
24
24
|
spec.add_dependency 'pliny', '>= 0.20.0'
|
25
|
+
spec.add_dependency 'librato-rack', '~> 2.0'
|
25
26
|
|
26
27
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
27
28
|
spec.add_development_dependency 'pry', '~> 0.10'
|
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.
|
4
|
+
version: 0.6.0
|
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-
|
12
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librato-metrics
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.20.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: librato-rack
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: bundler
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|