puma-newrelic 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03def45aa3c9dcd80d0084498954127447772e76848ed7069ce5f5bb034caa10
4
- data.tar.gz: f8752c312a107918d970db818baad203a47882112812c8d4d1dd290e36880ea8
3
+ metadata.gz: d71604cc58d401a09f4f6127cebce98b64b2c3a0192a5fb0aacf66b443943dc4
4
+ data.tar.gz: a39dd62912deca30c2fb9435a126f709cade9040023252ed22221237fdcb9167
5
5
  SHA512:
6
- metadata.gz: '0069e3777a22a0c48271db618043153532997624688dd737496656d152866afb25591cdd7909a046b25e4f68a8a3601d18c6b43d41349f5ea753ec1b255bf139'
7
- data.tar.gz: f70bf7889c60c3edfe4e9a1ce0ad4cabd8f073a0438b8d3cd66c58bcc097b9116f93329ee8face0854d4bfc663ccc7fba0ab2150363a0caf84c9ce5ef55d1a6c
6
+ metadata.gz: 5e394f02f72225ddc67f7141cbc1c8f240a7e4cd5473dd0156ef1537203e7e21d8a1e0db34a65da2ca51cd4e9ce553e890c23fabcb96f07f9b98eddfdb81d93a
7
+ data.tar.gz: 796b96233b9b5333cb86ef7f69f1a5b1beedcd790ca8b54d4d2fe03b38376f0950dbba57acfd5b80f72af852d5befbe5bb24c5269ca9e9d41e5b297421e50ff0
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ puma-newrelic (0.1.2)
5
+ puma (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.4.4)
11
+ nio4r (2.5.7)
12
+ puma (5.2.2)
13
+ nio4r (~> 2.0)
14
+ rake (12.3.3)
15
+ rspec (3.10.0)
16
+ rspec-core (~> 3.10.0)
17
+ rspec-expectations (~> 3.10.0)
18
+ rspec-mocks (~> 3.10.0)
19
+ rspec-core (3.10.1)
20
+ rspec-support (~> 3.10.0)
21
+ rspec-expectations (3.10.1)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-mocks (3.10.2)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-support (3.10.2)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ puma-newrelic!
34
+ rake (~> 12.0)
35
+ rspec (~> 3.0)
36
+
37
+ BUNDLED WITH
38
+ 2.1.4
data/README.md CHANGED
@@ -28,7 +28,7 @@ Or install it yourself as:
28
28
  * Create a dashboard on the NewRelic insights or NewRelic One
29
29
 
30
30
  NQRL example:
31
- ```
31
+ ```SQL
32
32
  SELECT rate(average(newrelic.timeslice.value), 1 minute)
33
33
  FROM Metric
34
34
  WHERE appName ='My App Name'
@@ -36,6 +36,18 @@ WITH METRIC_FORMAT 'Custom/Puma/pool_capacity'
36
36
  TIMESERIES FACET `host` LIMIT 10 SINCE 1800 seconds ago
37
37
  ```
38
38
 
39
+ ## Extra config in newrelic.yml
40
+ ```yaml
41
+ common: &default_settings
42
+ puma:
43
+ sample_rate: 15
44
+ keys:
45
+ - backlog
46
+ - running
47
+ - pool_capacity
48
+ - max_threads
49
+ ```
50
+
39
51
  ## Development
40
52
 
41
53
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.1.2
2
+ - Added config options
3
+
1
4
  # 0.1.1
2
5
  - Use hash stats for new version of puma (Thanks @mic-kul)
3
6
 
@@ -1,11 +1,11 @@
1
1
  module Puma
2
2
  module NewRelic
3
3
  class Sampler
4
- KEYS = %i(backlog running pool_capacity max_threads)
5
-
6
- def initialize(launcher, sample_rate)
4
+ def initialize(launcher)
5
+ config = ::NewRelic::Agent.config[:puma]
7
6
  @launcher = launcher
8
- @sample_rate = sample_rate
7
+ @sample_rate = config.fetch("sample_rate", 15)
8
+ @keys = config.fetch("keys", %i(backlog running pool_capacity max_threads))
9
9
  @last_sample_at = Time.now
10
10
  end
11
11
 
@@ -16,7 +16,7 @@ module Puma
16
16
  begin
17
17
  if should_sample?
18
18
  @last_sample_at = Time.now
19
- puma_stats = @launcher.stats
19
+ puma_stats = @launcher.stats
20
20
  if puma_stats.is_a?(Hash)
21
21
  parse puma_stats
22
22
  else
@@ -39,7 +39,7 @@ module Puma
39
39
 
40
40
  def parse(stats)
41
41
  metrics = Hash.new { |h, k| h[k] = 0 }
42
- sum = ->(key, value) { metrics[key] += value if KEYS.include?(key) }
42
+ sum = ->(key, value) { metrics[key] += value if @keys.include?(key) }
43
43
 
44
44
  if stats[:workers]
45
45
  metrics[:workers] = stats[:workers]
@@ -1,5 +1,5 @@
1
1
  module Puma
2
2
  module NewRelic
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ require 'puma/new_relic/sampler'
2
2
 
3
3
  Puma::Plugin.create do
4
4
  def start(launcher)
5
- sampler = Puma::NewRelic::Sampler.new(launcher, 15)
5
+ sampler = Puma::NewRelic::Sampler.new(launcher)
6
6
  launcher.events.register(:state) do |state|
7
7
  if %i[halt restart stop].include?(state)
8
8
  sampler.stop
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoist Claassen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -36,6 +36,7 @@ files:
36
36
  - ".travis.yml"
37
37
  - CODE_OF_CONDUCT.md
38
38
  - Gemfile
39
+ - Gemfile.lock
39
40
  - README.md
40
41
  - RELEASE_NOTES.md
41
42
  - Rakefile