puma-cloudwatch 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +5 -0
- data/lib/puma_cloudwatch/metrics/looper.rb +8 -1
- data/lib/puma_cloudwatch/metrics/sender.rb +23 -10
- data/lib/puma_cloudwatch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef9ffddc149af0d9bfbd27b26a36e81950f3744ec4111e56ff10f94d824133b0
|
4
|
+
data.tar.gz: a472a1792d0c98daaf40dbc58f6642d630963d5947c496fe7831056913390064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b083ddc6806fd2cd94c25870aa8318cced2cb62d8f8cf0fbfdf09196812221a84904b97813dd533f965a9afb1233632c18dd57c25c4a545b260a8b928c0f7278
|
7
|
+
data.tar.gz: 6c2af8d7dacd031777e4f75c993842cb94d5c51f1bf96190a9c7bd88de342e8bbdad417da9fb74fa28646edfa88432ef53f71acba9762f8f7c90a96bdbd54f90
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
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.5.2] - 2024-10-11
|
7
|
+
- [#16](https://github.com/tongueroo/puma-cloudwatch/pull/16) feat: permit multiple metric dimensions
|
8
|
+
|
9
|
+
## [0.5.1] - 2023-11-13
|
10
|
+
- [#13](https://github.com/tongueroo/puma-cloudwatch/pull/13) delay error messages until first successful fetch
|
11
|
+
|
6
12
|
## [0.5.0] - 2023-07-11
|
7
13
|
- [#11](https://github.com/tongueroo/puma-cloudwatch/pull/11) Added support for PUMA_CLOUDWATCH_AWS_ACCESS_KEY_ID and PUMA_CLOUDWATCH_AWS_SECRET_ACCESS_KEY env vars to configure an AWS access key
|
8
14
|
- [#12](https://github.com/tongueroo/puma-cloudwatch/pull/12) http tcp port support also
|
data/README.md
CHANGED
@@ -14,6 +14,10 @@ It also strongly encourage to set the `PUMA_CLOUDWATCH_DIMENSION_VALUE` env vari
|
|
14
14
|
|
15
15
|
PUMA_CLOUDWATCH_DIMENSION_VALUE=demo-web-puma
|
16
16
|
|
17
|
+
Or if you need to set multiple dimensions, you could use something like:
|
18
|
+
|
19
|
+
PUMA_CLOUDWATCH_DIMENSIONS="Service=web,Cluster=primary,Environment=production"
|
20
|
+
|
17
21
|
Then you can get metrics for your `demo-web-puma` app. List of metrics:
|
18
22
|
|
19
23
|
* pool_capacity: the number of requests that the server is capable of taking right now.
|
@@ -34,6 +38,7 @@ Env Var | Description | Default Value
|
|
34
38
|
PUMA\_CLOUDWATCH\_DEBUG | When set, the plugin prints out the metrics that get sent to CloudWatch. | (unset)
|
35
39
|
PUMA\_CLOUDWATCH\_DIMENSION\_NAME | CloudWatch metric dimension name | App
|
36
40
|
PUMA\_CLOUDWATCH\_DIMENSION\_VALUE | CloudWatch metric dimension value | puma
|
41
|
+
PUMA\_CLOUDWATCH\_DIMENSIONS | CloudWatch metric dimensions | (unset)
|
37
42
|
PUMA\_CLOUDWATCH\_ENABLED | Enables sending of the data to CloudWatch. | (unset)
|
38
43
|
PUMA\_CLOUDWATCH\_FREQUENCY | How often to send data to CloudWatch in seconds. | 60
|
39
44
|
PUMA\_CLOUDWATCH\_NAMESPACE | CloudWatch metric namespace | WebServer
|
@@ -10,6 +10,7 @@ class PumaCloudwatch::Metrics
|
|
10
10
|
@control_auth_token = options[:control_auth_token]
|
11
11
|
@frequency = Integer(ENV['PUMA_CLOUDWATCH_FREQUENCY'] || 60)
|
12
12
|
@enabled = ENV['PUMA_CLOUDWATCH_ENABLED'] || false
|
13
|
+
@fetched = false
|
13
14
|
end
|
14
15
|
|
15
16
|
def run
|
@@ -34,11 +35,17 @@ class PumaCloudwatch::Metrics
|
|
34
35
|
loop do
|
35
36
|
begin
|
36
37
|
stats = Fetcher.new(@options).call
|
38
|
+
@fetched = true
|
37
39
|
results = Parser.new(stats).call
|
38
40
|
Sender.new(results).call unless results.empty?
|
39
41
|
sleep @frequency
|
40
42
|
rescue Exception => e
|
41
|
-
|
43
|
+
if @fetched
|
44
|
+
puts "Error reached top of looper: #{e.message} (#{e.class})"
|
45
|
+
else
|
46
|
+
# sleep and don't error until we've successfully fetched
|
47
|
+
sleep @frequency
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
@@ -14,8 +14,7 @@ class PumaCloudwatch::Metrics
|
|
14
14
|
def initialize(metrics)
|
15
15
|
@metrics = metrics
|
16
16
|
@namespace = ENV['PUMA_CLOUDWATCH_NAMESPACE'] || "WebServer"
|
17
|
-
@
|
18
|
-
@dimension_value = ENV['PUMA_CLOUDWATCH_DIMENSION_VALUE'] || "puma"
|
17
|
+
@dimensions = calculate_dimensions
|
19
18
|
@frequency = Integer(ENV['PUMA_CLOUDWATCH_FREQUENCY'] || 60)
|
20
19
|
@enabled = ENV['PUMA_CLOUDWATCH_ENABLED'] || false
|
21
20
|
@region = ENV['PUMA_CLOUDWATCH_AWS_REGION']
|
@@ -23,6 +22,27 @@ class PumaCloudwatch::Metrics
|
|
23
22
|
@secret_access_key = ENV['PUMA_CLOUDWATCH_AWS_SECRET_ACCESS_KEY']
|
24
23
|
end
|
25
24
|
|
25
|
+
def calculate_dimensions
|
26
|
+
if ENV.key?('PUMA_CLOUDWATCH_DIMENSIONS')
|
27
|
+
ENV['PUMA_CLOUDWATCH_DIMENSIONS'].split(',').map(&:strip).map do |dimension|
|
28
|
+
name, value = dimension.split('=').map(&:strip)
|
29
|
+
|
30
|
+
{
|
31
|
+
name: name,
|
32
|
+
value: value,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
else
|
36
|
+
name = ENV['PUMA_CLOUDWATCH_DIMENSION_NAME'] || "App"
|
37
|
+
value = ENV['PUMA_CLOUDWATCH_DIMENSION_VALUE'] || "puma"
|
38
|
+
|
39
|
+
[
|
40
|
+
name: name,
|
41
|
+
value: value
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
26
46
|
def call
|
27
47
|
put_metric_data(
|
28
48
|
namespace: @namespace,
|
@@ -58,7 +78,7 @@ class PumaCloudwatch::Metrics
|
|
58
78
|
metric.each do |name, values|
|
59
79
|
data << {
|
60
80
|
metric_name: name.to_s,
|
61
|
-
dimensions: dimensions,
|
81
|
+
dimensions: @dimensions,
|
62
82
|
storage_resolution: @frequency < 60 ? 1 : 60,
|
63
83
|
statistic_values: {
|
64
84
|
sample_count: values.length,
|
@@ -72,13 +92,6 @@ class PumaCloudwatch::Metrics
|
|
72
92
|
data
|
73
93
|
end
|
74
94
|
|
75
|
-
def dimensions
|
76
|
-
[
|
77
|
-
name: @dimension_name,
|
78
|
-
value: @dimension_value
|
79
|
-
]
|
80
|
-
end
|
81
|
-
|
82
95
|
private
|
83
96
|
def put_metric_data(params)
|
84
97
|
if ENV['PUMA_CLOUDWATCH_DEBUG']
|
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.5.
|
4
|
+
version: 0.5.2
|
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: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-cloudwatch
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.5.10
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Puma plugin sends puma stats to CloudWatch
|