puma-newrelic 0.1.3 → 0.1.6

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: 903264ea9c94ce2fa615c8c6f3913027e1c4dbe6dc52f25813fb6162c5c262cd
4
- data.tar.gz: 17c687c789f5959d4979fc069a6a83b37693bd6bebe281f4aaabee0ef15a5a42
3
+ metadata.gz: b99194e339cf6b42d2caaebbff6c75e08bb7b91fec7c3853cf2072fcaf11339b
4
+ data.tar.gz: eee5af064f8583e65808b6f07cbb789b5329a904a1910dad6d25e7db4f86db61
5
5
  SHA512:
6
- metadata.gz: 4c215d14f1ae18f878d92fad82a6419ae9207c9c5957b7f1c5ef63e711043ae92ca048669d7ebc7338a4d21a0ff0173b0e6d992f169db0cb6e24f2b77918a898
7
- data.tar.gz: 3a660cf1ccd10c6e2ae808d8808fc58a7fa44bc7dd569be9ef683221015e45f666f15a5a352ff45459fa411eada96274a615fde996511983f46996f1d6bd38de
6
+ metadata.gz: fde05215131664dfe852260cb06c85e96e9c8e2b5a27f3b41e9795945ddb49093b75fa5fceff0db7fb11ffe200f0c61f6970797fd0b7fa2185ac5ed24b2c3e9b
7
+ data.tar.gz: 503f2204ee3545409e39226f2063d4a896c2d19efbe453dd820066a28536eceaf9a374f586d49c7de5f22e1f0ef0a526ebf1d8e81197d1f2aee20ca21a7e7ab7
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.idea/
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.1
data/Gemfile.lock CHANGED
@@ -1,15 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puma-newrelic (0.1.3)
4
+ puma-newrelic (0.1.5)
5
+ newrelic_rpm
5
6
  puma (>= 3.0)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  diff-lcs (1.4.4)
11
- nio4r (2.5.7)
12
- puma (5.2.2)
12
+ newrelic_rpm (8.6.0)
13
+ nio4r (2.5.8)
14
+ puma (5.6.4)
13
15
  nio4r (~> 2.0)
14
16
  rake (12.3.3)
15
17
  rspec (3.10.0)
data/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ # config.ru
2
+ run ->(env) do
3
+
4
+ end
@@ -2,10 +2,10 @@ module Puma
2
2
  module NewRelic
3
3
  class Sampler
4
4
  def initialize(launcher)
5
- config = ::NewRelic::Agent.config[:puma]
5
+ config = ::NewRelic::Agent.config[:puma] || {}
6
6
  @launcher = launcher
7
7
  @sample_rate = config.fetch("sample_rate", 15)
8
- @keys = config.fetch("keys", %w(backlog running pool_capacity max_threads)).map(&:to_sym)
8
+ @keys = config.fetch("keys", %w(backlog running pool_capacity max_threads)).map(&:to_s)
9
9
  @last_sample_at = Time.now
10
10
  end
11
11
 
@@ -39,15 +39,14 @@ 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) }
43
42
 
44
43
  if stats[:workers]
45
44
  metrics[:workers] = stats[:workers]
46
45
  stats[:worker_status].each do |worker|
47
- worker[:last_status].each(&sum)
46
+ worker[:last_status].each { |key, value| metrics[key.to_s] += value if @keys.include?(key.to_s) }
48
47
  end
49
48
  else
50
- stats.each(&sum)
49
+ stats.each { |key, value| metrics[key.to_s] += value if @keys.include?(key.to_s) }
51
50
  end
52
51
  report_metrics(metrics)
53
52
  end
@@ -1,5 +1,5 @@
1
1
  module Puma
2
2
  module NewRelic
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = "https://github.com/benoist/puma-newrelic"
12
12
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
13
  spec.add_runtime_dependency 'puma', '>= 3.0'
14
+ spec.add_runtime_dependency 'newrelic_rpm'
14
15
 
15
16
  # Specify which files should be added to the gem when it is released.
16
17
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
data/puma.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "newrelic_rpm"
2
+ require_relative "./lib/puma/plugin/new_relic_stats"
3
+ plugin 'new_relic_stats'
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.3
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoist Claassen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: newrelic_rpm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Samples the puma stats and creates a custom metric for NewRelic
28
42
  email:
29
43
  - benoist.claassen@gmail.com
@@ -33,6 +47,7 @@ extra_rdoc_files: []
33
47
  files:
34
48
  - ".gitignore"
35
49
  - ".rspec"
50
+ - ".ruby-version"
36
51
  - ".travis.yml"
37
52
  - CODE_OF_CONDUCT.md
38
53
  - Gemfile
@@ -42,10 +57,12 @@ files:
42
57
  - Rakefile
43
58
  - bin/console
44
59
  - bin/setup
60
+ - config.ru
45
61
  - lib/puma/new_relic/sampler.rb
46
62
  - lib/puma/new_relic/version.rb
47
63
  - lib/puma/plugin/new_relic_stats.rb
48
64
  - puma-newrelic.gemspec
65
+ - puma.rb
49
66
  homepage: https://github.com/benoist/puma-newrelic
50
67
  licenses: []
51
68
  metadata: {}
@@ -64,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
81
  - !ruby/object:Gem::Version
65
82
  version: '0'
66
83
  requirements: []
67
- rubygems_version: 3.0.3
84
+ rubygems_version: 3.3.7
68
85
  signing_key:
69
86
  specification_version: 4
70
87
  summary: New Relic Puma Stats sampler