puma-cloudwatch 0.3.1 → 0.4.4
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +3 -1
- data/lib/puma_cloudwatch/core_ext.rb +0 -1
- data/lib/puma_cloudwatch/metrics/looper.rb +8 -4
- data/lib/puma_cloudwatch/metrics/sender.rb +16 -2
- data/lib/puma_cloudwatch/version.rb +1 -1
- metadata +3 -4
- data/lib/puma_cloudwatch/core_ext/array.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e2897967164e24f709d8c976d1fd9a5b741a01d020c2da8dcb191a9d4fe43ab
|
4
|
+
data.tar.gz: bdb6f674505cd71c8423dd343c77a8521715425de02c2a6b418c1b9575e10d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0658266b02fa7ffa618b94bdc956c12b6536cb2eea17dcf2b7a4c39452b7adf1d96bc2e83544568739bc998ee9c76cf90416b9db3d2b174bcf9d759a0b07266a'
|
7
|
+
data.tar.gz: de176da8000aec589ed539b3f0f6538a602344aab633c5dc7216307e21662f31405361525de134f0169288312af414c79b5065b14ff16a71bf257047ab9bc69d
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,21 @@
|
|
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.4]
|
7
|
+
- #4 fix syntax error in older versions of ruby
|
8
|
+
|
9
|
+
## [0.4.3]
|
10
|
+
- #3 Eliminate the need to add Array#sum
|
11
|
+
|
12
|
+
## [0.4.2]
|
13
|
+
- #2 keep looper running on adversities
|
14
|
+
|
15
|
+
## [0.4.1]
|
16
|
+
- #1 empty results breaks cloudwatch put_metric_data
|
17
|
+
|
18
|
+
## [0.4.0]
|
19
|
+
- improve AWS IAM setup and permission errors so Thread loop doesnt stop
|
20
|
+
|
6
21
|
## [0.3.1]
|
7
22
|
- fix PUMA_CLOUDWATCH_MUTE_START_MESSAGE var
|
8
23
|
|
data/README.md
CHANGED
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/puma-cloudwatch)
|
4
4
|
|
5
|
+
[](https://www.boltops.com)
|
6
|
+
|
5
7
|
A [puma](https://puma.io) plugin that sends puma stats to CloudWatch.
|
6
8
|
|
7
9
|
## Usage
|
8
10
|
|
9
11
|
**Important**: To enable the plugin to send metrics to CloudWatch you must set the `PUMA_CLOUDWATCH_ENABLED` env variable. This allows you to send only metrics on configured servers and not unintentionally send them locally.
|
10
12
|
|
11
|
-
It also strongly encourage to
|
13
|
+
It also strongly encourage to set the `PUMA_CLOUDWATCH_DIMENSION_VALUE` env variable to include your application name. For example, if your application is named "demo-web", this would be a good value to use:
|
12
14
|
|
13
15
|
PUMA_CLOUDWATCH_DIMENSION_VALUE=demo-web-puma
|
14
16
|
|
@@ -32,10 +32,14 @@ class PumaCloudwatch::Metrics
|
|
32
32
|
private
|
33
33
|
def perform
|
34
34
|
loop do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
|
@@ -57,7 +57,7 @@ class PumaCloudwatch::Metrics
|
|
57
57
|
dimensions: dimensions,
|
58
58
|
statistic_values: {
|
59
59
|
sample_count: values.length,
|
60
|
-
sum: values.sum,
|
60
|
+
sum: values.inject(0) { |sum, el| sum += el },
|
61
61
|
minimum: values.min,
|
62
62
|
maximum: values.max
|
63
63
|
}
|
@@ -84,7 +84,15 @@ class PumaCloudwatch::Metrics
|
|
84
84
|
end
|
85
85
|
|
86
86
|
if enabled?
|
87
|
-
|
87
|
+
begin
|
88
|
+
cloudwatch.put_metric_data(params)
|
89
|
+
rescue Aws::CloudWatch::Errors::AccessDenied => e
|
90
|
+
puts "WARN: #{e.class} #{e.message}"
|
91
|
+
puts "Unable to send metrics to CloudWatch"
|
92
|
+
rescue PumaCloudwatch::Error => e
|
93
|
+
puts "WARN: #{e.class} #{e.message}"
|
94
|
+
puts "Unable to send metrics to CloudWatch"
|
95
|
+
end
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
@@ -94,6 +102,12 @@ class PumaCloudwatch::Metrics
|
|
94
102
|
|
95
103
|
def cloudwatch
|
96
104
|
@cloudwatch ||= Aws::CloudWatch::Client.new
|
105
|
+
rescue Aws::Errors::MissingRegionError => e
|
106
|
+
# Happens when:
|
107
|
+
# 1. ~/.aws/config is not also setup locally
|
108
|
+
# 2. On EC2 instance when AWS_REGION not set
|
109
|
+
puts "WARN: #{e.class} #{e.message}"
|
110
|
+
raise PumaCloudwatch::Error.new(e.message)
|
97
111
|
end
|
98
112
|
end
|
99
113
|
end
|
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
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-26 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
|
@@ -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.
|
117
|
+
rubygems_version: 3.1.2
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: Puma plugin sends puma stats to CloudWatch
|