pliny-librato 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d70a0b565fba48c9b53ad27bc88b6e9beacd7f94
4
- data.tar.gz: 1e40f86dcdf0316c8792b0f667b42994a06d2291
3
+ metadata.gz: 362932985964ab9a8467c82061e5a6950a6d12ef
4
+ data.tar.gz: 1243663968f6966454a4a537185654f30725f9c3
5
5
  SHA512:
6
- metadata.gz: d35115fbe573b69129f382e8b4f827ea83d21bebdc8955b0b4ac095643f19b4d7eb9daf62706260c5983d6ec6df84a88822c3448662df040b6e513f3bdf6f65a
7
- data.tar.gz: a710b8488472f98981542272dbb371911364a6f04e64ce4063f638f3bf6f1ef90111e14854c493e449f1f2fcfab0fd23886346632ff865f8a65b89ccdb95285c
6
+ metadata.gz: c666a43801fda7e4730e8933dfdec3c76aecb2d31a681d6448f08506ece4c45c4bfcba8873aec9ce5e31b8b5ca6528206fe1e4a9f119a4755f60103b94d47f43
7
+ data.tar.gz: 96e7b31fe8e42ef8e7bc61b14306546ebaea28547c607f4d5c638b5b3711c4d6fd4e83429227a044fca6f17a35149a5224984de4c9a7ee6c35cc4e3b8a604e1b
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 0.4.0
10
+
11
+ ### Added
12
+
13
+ - The backend now queues metrics and sends in batches
14
+ - You can specify the `count` and `interval` for batch sends when initializing
15
+ the backend.
16
+
17
+ ### Removed
18
+
19
+ - `concurrent-ruby` is no longer a dependency.
20
+
9
21
  ## 0.3.0
10
22
 
11
23
  ### Changed
@@ -15,4 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
15
27
  "count#" entries, which are also submitted as gauges.
16
28
 
17
29
  ## 0.2.0
30
+
31
+ ### Changed
32
+
18
33
  - Catch and report errors in async calls to the Librato API
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pliny-librato (0.2.0)
5
- concurrent-ruby (~> 1.0)
4
+ pliny-librato (0.3.0)
6
5
  librato-metrics (~> 2.0)
7
6
  pliny (>= 0.20.0)
8
7
 
@@ -18,7 +17,6 @@ GEM
18
17
  aggregate (0.2.2)
19
18
  byebug (9.0.6)
20
19
  coderay (1.1.1)
21
- concurrent-ruby (1.0.2)
22
20
  diff-lcs (1.2.5)
23
21
  erubis (2.7.0)
24
22
  faraday (0.10.0)
@@ -26,7 +24,7 @@ GEM
26
24
  http_accept (0.1.6)
27
25
  i18n (0.7.0)
28
26
  json (1.8.3)
29
- json_schema (0.15.0)
27
+ json_schema (0.16.0)
30
28
  librato-metrics (2.0.2)
31
29
  aggregate (~> 0.2.2)
32
30
  faraday
@@ -34,7 +32,7 @@ GEM
34
32
  minitest (5.10.1)
35
33
  multi_json (1.12.1)
36
34
  multipart-post (2.0.0)
37
- pliny (0.20.1)
35
+ pliny (0.21.0)
38
36
  activesupport (~> 4.1, >= 4.1.0)
39
37
  http_accept (~> 0.1, >= 0.1.5)
40
38
  multi_json (~> 1.9, >= 1.9.3)
@@ -42,7 +40,7 @@ GEM
42
40
  sinatra (~> 1.4, >= 1.4.7)
43
41
  sinatra-router (~> 0.2, >= 0.2.3)
44
42
  thor (~> 0.19, >= 0.19.1)
45
- prmd (0.12.0)
43
+ prmd (0.13.0)
46
44
  erubis (~> 2.7)
47
45
  json_schema (~> 0.3, >= 0.3.1)
48
46
  pry (0.10.4)
data/README.md CHANGED
@@ -27,7 +27,8 @@ Librato::Metrics.authenticate(Config.librato_email, Config.librato_key)
27
27
  Pliny::Metrics.backends << Pliny::Librato::Metrics::Backend.new(source: "myapp.production")
28
28
  ```
29
29
 
30
- Now `Pliny::Metrics` methods send directly to Librato:
30
+ Now `Pliny::Metrics` methods will build a queue and automatically send metrics
31
+ to Librato.
31
32
 
32
33
  ```ruby
33
34
  Pliny::Metrics.count(:foo, 3)
@@ -36,6 +37,9 @@ Pliny::Metrics.measure(:bar) do
36
37
  end
37
38
  ```
38
39
 
40
+ By default, it will send queued metrics every minute, or whenever the
41
+ queue reaches 1000 metrics. These settings can be configured on initialization.
42
+
39
43
  ## Development
40
44
 
41
45
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -44,4 +48,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
44
48
 
45
49
  ## Contributing
46
50
 
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pliny-librato.
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/heroku/pliny-librato.
@@ -1,39 +1,41 @@
1
- require "librato/metrics"
2
- require "concurrent"
3
- require "pliny/error_reporters"
4
-
5
- module Pliny::Librato
6
- module Metrics
7
- class Backend
8
- include Concurrent::Async
9
-
10
- def initialize(source: nil)
11
- super()
12
- @source = source
13
- end
14
-
15
- def report_counts(counts)
16
- self.async.report(counts)
17
- end
1
+ require 'librato/metrics'
2
+ require 'pliny/error_reporters'
3
+
4
+ module Pliny
5
+ module Librato
6
+ module Metrics
7
+ # Implements the Pliny::Metrics.backends API. Puts any metrics sent
8
+ # from Pliny::Metrics onto a queue that gets submitted in batches.
9
+ class Backend
10
+ attr_reader :queue
11
+
12
+ def initialize(source: nil, interval: 60, count: 1000, queue: nil)
13
+ @queue = queue || ::Librato::Metrics::Queue.new(
14
+ source: source,
15
+ autosubmit_interval: interval,
16
+ autosubmit_count: count
17
+ )
18
+ flush_on_shutdown
19
+ end
18
20
 
19
- def report_measures(measures)
20
- self.async.report(measures)
21
- end
21
+ def report_counts(counts)
22
+ report(counts)
23
+ end
22
24
 
23
- def report(metrics)
24
- ::Librato::Metrics.submit(serialize(metrics))
25
- rescue => error
26
- Pliny::ErrorReporters.notify(error)
27
- end
25
+ def report_measures(measures)
26
+ report(measures)
27
+ end
28
28
 
29
- private
29
+ private
30
30
 
31
- attr_reader :librato_client, :source
31
+ def report(metrics)
32
+ queue.add(metrics)
33
+ rescue => error
34
+ Pliny::ErrorReporters.notify(error)
35
+ end
32
36
 
33
- def serialize(metrics)
34
- metrics.reduce({}) do |mets, (k, v)|
35
- mets[k] = { type: :gauge, value: v, source: source }
36
- mets
37
+ def flush_on_shutdown
38
+ Signal.trap('TERM') { queue.submit }
37
39
  end
38
40
  end
39
41
  end
@@ -1,5 +1,5 @@
1
1
  module Pliny
2
2
  module Librato
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -4,30 +4,29 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'pliny/librato/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "pliny-librato"
7
+ spec.name = 'pliny-librato'
8
8
  spec.version = Pliny::Librato::VERSION
9
- spec.authors = ["Andrew Appleton", "Josh W Lewis"]
10
- spec.email = "andysapple@gmail.com"
9
+ spec.authors = ['Andrew Appleton', 'Josh W Lewis']
10
+ spec.email = 'andysapple@gmail.com'
11
11
 
12
- spec.summary = %q{A Librato metrics reporter backend for pliny}
13
- spec.homepage = "https://github.com/appleton/pliny-librato"
12
+ spec.summary = 'A Librato metrics reporter backend for pliny'
13
+ spec.homepage = 'https://github.com/appleton/pliny-librato'
14
14
 
15
- spec.licenses = ["MIT"]
15
+ spec.licenses = ['MIT']
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency "concurrent-ruby", "~> 1.0"
24
- spec.add_dependency "librato-metrics", "~> 2.0"
25
- spec.add_dependency "pliny", ">= 0.20.0"
23
+ spec.add_dependency 'librato-metrics', '~> 2.0'
24
+ spec.add_dependency 'pliny', '>= 0.20.0'
26
25
 
27
- spec.add_development_dependency "bundler", "~> 1.13"
28
- spec.add_development_dependency "pry", "~> 0.10"
29
- spec.add_development_dependency "pry-byebug", "~> 3.4"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.3"
32
- spec.add_development_dependency "timecop", "~> 0.8.1"
26
+ spec.add_development_dependency 'bundler', '~> 1.13'
27
+ spec.add_development_dependency 'pry', '~> 0.10'
28
+ spec.add_development_dependency 'pry-byebug', '~> 3.4'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.3'
31
+ spec.add_development_dependency 'timecop', '~> 0.8.1'
33
32
  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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Appleton
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-08 00:00:00.000000000 Z
12
+ date: 2016-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: concurrent-ruby
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '1.0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: librato-metrics
30
16
  requirement: !ruby/object:Gem::Requirement