cloudwatch-metrics 1.1.0 → 1.1.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c05a115e1d85721a94703a582811740101ded81e2eaab2bbbbf6812a28d5d02e
|
4
|
+
data.tar.gz: 9cc9c8113894d10d20592206c4c0131e281e3b8973be026f3d9c7d907dca6b98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d062eff18b802d34fb9b1126d52297832d339beac6dfc0db6af23ebe131c0c11b28281140e9bd8f631943ad625ce7f1160409d8c2aad36c8941abcaa0e79cd
|
7
|
+
data.tar.gz: 600219d188edd77b5969fbfafe3633ed888abba04afc40edb43e99f06189b5b1cdf155c5056ebdf5ffcfd99126e2f4f5571ab05cefefdd76b4932fa117f2848d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cloudwatch-metrics (1.
|
4
|
+
cloudwatch-metrics (1.1.2)
|
5
5
|
activesupport (~> 7.0)
|
6
6
|
aws-sdk-cloudwatch (~> 1.73)
|
7
7
|
rake (~> 13.0)
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
tzinfo (~> 2.0)
|
17
17
|
ast (2.4.2)
|
18
18
|
aws-eventstream (1.2.0)
|
19
|
-
aws-partitions (1.
|
19
|
+
aws-partitions (1.781.0)
|
20
20
|
aws-sdk-cloudwatch (1.75.0)
|
21
21
|
aws-sdk-core (~> 3, >= 3.174.0)
|
22
22
|
aws-sigv4 (~> 1.1)
|
data/lib/cloudwatch_metrics.rb
CHANGED
@@ -45,6 +45,8 @@ module CloudwatchMetrics
|
|
45
45
|
timestamp: timestamp
|
46
46
|
}]
|
47
47
|
put_data(namespace: full_namespace(namespace), metric_data: metric_data)
|
48
|
+
rescue StandardError => e
|
49
|
+
handle_error(e)
|
48
50
|
end
|
49
51
|
|
50
52
|
def record_all(
|
@@ -59,6 +61,8 @@ module CloudwatchMetrics
|
|
59
61
|
timestamp: timestamp
|
60
62
|
}]
|
61
63
|
put_data(namespace: full_namespace(namespace), metric_data: metric_data)
|
64
|
+
rescue StandardError => e
|
65
|
+
handle_error(e)
|
62
66
|
end
|
63
67
|
|
64
68
|
private
|
@@ -71,8 +75,6 @@ module CloudwatchMetrics
|
|
71
75
|
end
|
72
76
|
|
73
77
|
nil
|
74
|
-
rescue StandardError => e
|
75
|
-
handle_error(e)
|
76
78
|
end
|
77
79
|
|
78
80
|
def cloudwatch_client
|
@@ -90,20 +92,19 @@ module CloudwatchMetrics
|
|
90
92
|
end
|
91
93
|
|
92
94
|
# convert key/value hash to format expected by AWS SDK
|
95
|
+
# ignore any keys with blank values
|
93
96
|
def map_dimensions(dimensions)
|
94
97
|
combined_dimensions = (configuration.default_dimensions || {}).merge(dimensions || {})
|
95
98
|
|
96
99
|
mapped_values = []
|
97
100
|
combined_dimensions.keys.each do |key|
|
98
|
-
mapped_values << {
|
99
|
-
name: key.to_s,
|
100
|
-
value: combined_dimensions[key]
|
101
|
-
}
|
101
|
+
mapped_values << {name: key.to_s, value: combined_dimensions[key]} if combined_dimensions[key].present?
|
102
102
|
end
|
103
103
|
|
104
104
|
mapped_values
|
105
105
|
end
|
106
106
|
|
107
|
+
# handle error by calling configured error handler or logging and raising
|
107
108
|
def handle_error(error)
|
108
109
|
if !configuration.error_handler.nil?
|
109
110
|
configuration.error_handler.call(error)
|
@@ -114,9 +115,10 @@ module CloudwatchMetrics
|
|
114
115
|
raise CloudwatchMetrics::Error, error.message
|
115
116
|
end
|
116
117
|
|
118
|
+
# get namespace from configuration or use provided value and apply non-production prefix if applicable
|
117
119
|
def full_namespace(provided_namespace)
|
118
120
|
constructed_namespace = provided_namespace || configuration.namespace
|
119
|
-
raise CloudwatchMetrics::Error, 'Namespace must be provided' if constructed_namespace.
|
121
|
+
raise CloudwatchMetrics::Error, 'Namespace must be provided' if constructed_namespace.blank?
|
120
122
|
|
121
123
|
if environment != 'production' && configuration.non_production_prefix.present?
|
122
124
|
constructed_namespace = configuration.non_production_prefix + constructed_namespace
|
@@ -35,7 +35,7 @@ CloudwatchMetrics.configure do |config|
|
|
35
35
|
|
36
36
|
# This is an optional configuration to set the namespace prefix for non-production
|
37
37
|
# environments. This is useful if you want to avoid polluting your production
|
38
|
-
# metrics with test data. Defaults to 'test-'.
|
38
|
+
# metrics with test data. If empty or nil no prefix will be applied. Defaults to 'test-'.
|
39
39
|
# config.non_production_prefix = 'test-'
|
40
40
|
|
41
41
|
# This is an optional configuration to set an error handler proc.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudwatch-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Puckett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|