puma-cloudwatch 0.4.1 → 0.4.5

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: 7073822e443681c139f50b223c69f574890cc58d20d33725fc213eba4e939f0d
4
- data.tar.gz: 57af436b11b42670171faaeb113ab84eacb9e7931c6c2435d60d0b503c800301
3
+ metadata.gz: 70ae556e3b7f637e097d36d0296652566b0dae5c66f1d257013b1653393cf7c4
4
+ data.tar.gz: 80e4da1709178513fc7e8057bb800d15a87e6e2c261b0b5e6916ad10f41eaf04
5
5
  SHA512:
6
- metadata.gz: b93cb4a76626df2907125496723cc0ea04fa45c803ad264a9f311f6f59c504280c805f4d2ef53ac0d4f4b13d17fa2a5d70fa34e396c277399a9d6104412d333f
7
- data.tar.gz: 718327a2f7ae56c7f5aefe670fb09e375e115eb26ab9c49d3ba70f2df135eeeaae9e2e7e7a14078167a219b507ad6e4515b4cb427d85105e2eff0240a2fd482a
6
+ metadata.gz: 4d8f25242c010a545080e1236e9f9b6b3b608c660f6a096bbace315632cd2326925e4f322fda0bdf2b31195f5b898c09a2bf7f20c922d3daf6cd657d8e31014a
7
+ data.tar.gz: 998bf6b0ebcd485d5a7212ccc0a2f189ebf588c6b08652f3549628d5dfc97fd6d93eb054ee6f8f670284d1d54453290b6b12bd02f5d470bc2de9db59c3ef6265
data/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.4.5] - 2021-11-09
7
+ - [#5](https://github.com/boltops-tools/puma-cloudwatch/pull/5) Enabling high-resolution Cloudwatch metrics if frequency is lower tha…
8
+
9
+ ## [0.4.4]
10
+ - #4 fix syntax error in older versions of ruby
11
+
12
+ ## [0.4.3]
13
+ - #3 Eliminate the need to add Array#sum
14
+
15
+ ## [0.4.2]
16
+ - #2 keep looper running on adversities
17
+
6
18
  ## [0.4.1]
7
19
  - #1 empty results breaks cloudwatch put_metric_data
8
20
 
data/README.md CHANGED
@@ -80,4 +80,4 @@ If are you using ECS awsvpc, make sure you have the task running on private subn
80
80
 
81
81
  ## Contributing
82
82
 
83
- Bug reports and pull requests are welcome on GitHub at https://github.com/tongueroo/puma-cloudwatch
83
+ Bug reports and pull requests are welcome on GitHub at https://github.com/boltops-tools/puma-cloudwatch
@@ -2,6 +2,5 @@
2
2
  major, minor, _ = RUBY_VERSION.split('.')
3
3
  if major == '2' && minor == '3'
4
4
  require "puma_cloudwatch/core_ext/thread"
5
- require "puma_cloudwatch/core_ext/array"
6
5
  require "pp"
7
6
  end
@@ -32,10 +32,14 @@ class PumaCloudwatch::Metrics
32
32
  private
33
33
  def perform
34
34
  loop do
35
- stats = Fetcher.new(@options).call
36
- results = Parser.new(stats).call
37
- Sender.new(results).call unless results.empty?
38
- sleep @frequency
35
+ begin
36
+ stats = Fetcher.new(@options).call
37
+ results = Parser.new(stats).call
38
+ Sender.new(results).call unless results.empty?
39
+ sleep @frequency
40
+ rescue Exception => e
41
+ puts "Error reached top of looper: #{e.message} (#{e.class})"
42
+ end
39
43
  end
40
44
  end
41
45
 
@@ -16,6 +16,7 @@ class PumaCloudwatch::Metrics
16
16
  @namespace = ENV['PUMA_CLOUDWATCH_NAMESPACE'] || "WebServer"
17
17
  @dimension_name = ENV['PUMA_CLOUDWATCH_DIMENSION_NAME'] || "App"
18
18
  @dimension_value = ENV['PUMA_CLOUDWATCH_DIMENSION_VALUE'] || "puma"
19
+ @frequency = Integer(ENV['PUMA_CLOUDWATCH_FREQUENCY'] || 60)
19
20
  @enabled = ENV['PUMA_CLOUDWATCH_ENABLED'] || false
20
21
  end
21
22
 
@@ -55,9 +56,10 @@ class PumaCloudwatch::Metrics
55
56
  data << {
56
57
  metric_name: name.to_s,
57
58
  dimensions: dimensions,
59
+ storage_resolution: @frequency < 60 ? 1 : 60,
58
60
  statistic_values: {
59
61
  sample_count: values.length,
60
- sum: values.sum,
62
+ sum: values.inject(0) { |sum, el| sum += el },
61
63
  minimum: values.min,
62
64
  maximum: values.max
63
65
  }
@@ -1,3 +1,3 @@
1
1
  module PumaCloudwatch
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["tongueroo@gmail.com"]
10
10
 
11
11
  spec.summary = "Puma plugin sends puma stats to CloudWatch"
12
- spec.homepage = "https://github.com/tongueroo/puma-cloudwatch"
12
+ spec.homepage = "https://github.com/boltops-tools/puma-cloudwatch"
13
13
  spec.license = "MIT"
14
14
 
15
15
  # Specify which files should be added to the gem when it is released.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-cloudwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudwatch
@@ -87,7 +87,6 @@ files:
87
87
  - lib/puma/plugin/cloudwatch.rb
88
88
  - lib/puma_cloudwatch.rb
89
89
  - lib/puma_cloudwatch/core_ext.rb
90
- - lib/puma_cloudwatch/core_ext/array.rb
91
90
  - lib/puma_cloudwatch/core_ext/thread.rb
92
91
  - lib/puma_cloudwatch/metrics.rb
93
92
  - lib/puma_cloudwatch/metrics/fetcher.rb
@@ -96,7 +95,7 @@ files:
96
95
  - lib/puma_cloudwatch/metrics/sender.rb
97
96
  - lib/puma_cloudwatch/version.rb
98
97
  - puma-cloudwatch.gemspec
99
- homepage: https://github.com/tongueroo/puma-cloudwatch
98
+ homepage: https://github.com/boltops-tools/puma-cloudwatch
100
99
  licenses:
101
100
  - MIT
102
101
  metadata: {}
@@ -115,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
114
  - !ruby/object:Gem::Version
116
115
  version: '0'
117
116
  requirements: []
118
- rubygems_version: 3.1.2
117
+ rubygems_version: 3.1.6
119
118
  signing_key:
120
119
  specification_version: 4
121
120
  summary: Puma plugin sends puma stats to CloudWatch
@@ -1,7 +0,0 @@
1
- class Array
2
- # Note: Array#sum only available in ruby 2.4+
3
- # Thanks: http://www.viarails.net/q/How-to-sum-an-array-of-numbers-in-Ruby
4
- def sum
5
- inject(0) {|sum, i| sum + i }
6
- end
7
- end