puma-newrelic 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 5769a5858c17962efa9a1a6ea526af1fc137fa694a1b3fc5e3a4fbc65d8108c8
4
- data.tar.gz: 13a875db19065aafe345e047aef97365c19fc4fc16c57b4dd025929f94a87adf
3
+ metadata.gz: 03def45aa3c9dcd80d0084498954127447772e76848ed7069ce5f5bb034caa10
4
+ data.tar.gz: f8752c312a107918d970db818baad203a47882112812c8d4d1dd290e36880ea8
5
5
  SHA512:
6
- metadata.gz: 377bbdafe5959ff321de9953aed0d880c6047d6fb1e46de978f825b52cf931736a73c192416218e23b4d47314ab5acb1db320f7097d2db98eebb8d86a6003e26
7
- data.tar.gz: 6f4e9144aad5b4763dbb04006b60869a99f7f7ed6427471acfb0681072a9ead28b7a43f4a3c9a95ccba5867c26f575d2922e37c9636754d2dfe9c5731244dadb
6
+ metadata.gz: '0069e3777a22a0c48271db618043153532997624688dd737496656d152866afb25591cdd7909a046b25e4f68a8a3601d18c6b43d41349f5ea753ec1b255bf139'
7
+ data.tar.gz: f70bf7889c60c3edfe4e9a1ce0ad4cabd8f073a0438b8d3cd66c58bcc097b9116f93329ee8face0854d4bfc663ccc7fba0ab2150363a0caf84c9ce5ef55d1a6c
data/README.md CHANGED
@@ -24,9 +24,18 @@ Or install it yourself as:
24
24
  ## Usage
25
25
 
26
26
  * Install the gem
27
- * Add `plugin 'new-relic-stats'` to your puma.rb
27
+ * Add `plugin 'new_relic_stats'` to your puma.rb
28
28
  * Create a dashboard on the NewRelic insights or NewRelic One
29
29
 
30
+ NQRL example:
31
+ ```
32
+ SELECT rate(average(newrelic.timeslice.value), 1 minute)
33
+ FROM Metric
34
+ WHERE appName ='My App Name'
35
+ WITH METRIC_FORMAT 'Custom/Puma/pool_capacity'
36
+ TIMESERIES FACET `host` LIMIT 10 SINCE 1800 seconds ago
37
+ ```
38
+
30
39
  ## Development
31
40
 
32
41
  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.
@@ -0,0 +1,5 @@
1
+ # 0.1.1
2
+ - Use hash stats for new version of puma (Thanks @mic-kul)
3
+
4
+ # O.1.0
5
+ - Initial version
@@ -1,7 +1,7 @@
1
1
  module Puma
2
2
  module NewRelic
3
3
  class Sampler
4
- KEYS = %w(backlog running pool_capacity max_threads)
4
+ KEYS = %i(backlog running pool_capacity max_threads)
5
5
 
6
6
  def initialize(launcher, sample_rate)
7
7
  @launcher = launcher
@@ -16,8 +16,12 @@ module Puma
16
16
  begin
17
17
  if should_sample?
18
18
  @last_sample_at = Time.now
19
-
20
- parse JSON.parse(@launcher.stats)
19
+ puma_stats = @launcher.stats
20
+ if puma_stats.is_a?(Hash)
21
+ parse puma_stats
22
+ else
23
+ parse JSON.parse(puma_stats, symbolize_names: true)
24
+ end
21
25
  end
22
26
  rescue Exception => e
23
27
  ::NewRelic::Agent.logger.error(e.message)
@@ -37,10 +41,10 @@ module Puma
37
41
  metrics = Hash.new { |h, k| h[k] = 0 }
38
42
  sum = ->(key, value) { metrics[key] += value if KEYS.include?(key) }
39
43
 
40
- if stats["workers"]
41
- metrics["workers"] = stats["workers"]
42
- stats["worker_status"].each do |worker|
43
- worker["last_status"].each(&sum)
44
+ if stats[:workers]
45
+ metrics[:workers] = stats[:workers]
46
+ stats[:worker_status].each do |worker|
47
+ worker[:last_status].each(&sum)
44
48
  end
45
49
  else
46
50
  stats.each(&sum)
@@ -1,5 +1,5 @@
1
1
  module Puma
2
2
  module NewRelic
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoist Claassen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-14 00:00:00.000000000 Z
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -37,6 +37,7 @@ files:
37
37
  - CODE_OF_CONDUCT.md
38
38
  - Gemfile
39
39
  - README.md
40
+ - RELEASE_NOTES.md
40
41
  - Rakefile
41
42
  - bin/console
42
43
  - bin/setup
@@ -47,7 +48,7 @@ files:
47
48
  homepage: https://github.com/benoist/puma-newrelic
48
49
  licenses: []
49
50
  metadata: {}
50
- post_install_message:
51
+ post_install_message:
51
52
  rdoc_options: []
52
53
  require_paths:
53
54
  - lib
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  version: '0'
64
65
  requirements: []
65
66
  rubygems_version: 3.0.3
66
- signing_key:
67
+ signing_key:
67
68
  specification_version: 4
68
69
  summary: New Relic Puma Stats sampler
69
70
  test_files: []