puma-cloudwatch 0.5.1 → 0.5.2

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: 599b6819f8b72237a6fee5a64c7e0f9060da208b80291a24f5bf3b3b7cf93eef
4
- data.tar.gz: e53f1ff64f41be6c3349a8d8a009ab7ccebcfec0d82c1b2f03fd318338250d15
3
+ metadata.gz: ef9ffddc149af0d9bfbd27b26a36e81950f3744ec4111e56ff10f94d824133b0
4
+ data.tar.gz: a472a1792d0c98daaf40dbc58f6642d630963d5947c496fe7831056913390064
5
5
  SHA512:
6
- metadata.gz: 4f1dca7162a90b61399dda3b6ca7b3807ef95323be856c7ac9c74a94b70c14c65e8aaa6bca18b092c85ae4fce5c3ef8e71027a2ca39a02f774b41a8f5143fe38
7
- data.tar.gz: 29d39a09ce1e5ff472ba549fd20356f7ae7e2826aab2d40ce2471b4d5f7d54e757d88c2f689dea637127439504fcc11a1d8dadbe5b793caffa0463a2fd68ff20
6
+ metadata.gz: b083ddc6806fd2cd94c25870aa8318cced2cb62d8f8cf0fbfdf09196812221a84904b97813dd533f965a9afb1233632c18dd57c25c4a545b260a8b928c0f7278
7
+ data.tar.gz: 6c2af8d7dacd031777e4f75c993842cb94d5c51f1bf96190a9c7bd88de342e8bbdad417da9fb74fa28646edfa88432ef53f71acba9762f8f7c90a96bdbd54f90
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
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
+
6
9
  ## [0.5.1] - 2023-11-13
7
10
  - [#13](https://github.com/tongueroo/puma-cloudwatch/pull/13) delay error messages until first successful fetch
8
11
 
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
@@ -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
- @dimension_name = ENV['PUMA_CLOUDWATCH_DIMENSION_NAME'] || "App"
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']
@@ -1,3 +1,3 @@
1
1
  module PumaCloudwatch
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  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.5.1
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: 2023-11-13 00:00:00.000000000 Z
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.4.20
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