cloudwatch-metrics 1.1.1 → 1.1.3

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: aae5940338cdbe6a8908f6330531daa21de3bebe3c63a84e5c8c30fbace3413e
4
- data.tar.gz: 15cf0039191265a80066547276459f60f584bfd70924574b0719d65838b13bc3
3
+ metadata.gz: 9f09863337a7fd11e3f2f549b23b27c574a008662ecf66283ffd614e82a95922
4
+ data.tar.gz: 72362a407b63b87d9bb68e971bcf7f02340197d8c77648aae459d4f7c9274508
5
5
  SHA512:
6
- metadata.gz: 7c0a974cd1dd8a00473fabefa3be9721f0ce08ca832791c0e7fc764baf3d3111177d64583e30e822473392f746e5afb52a2908586d8ee87b39238283d9509556
7
- data.tar.gz: 021f06249687423051df6bc8f0adf113be020666fa0b3184b16e36bb4c174d1333c4eb90043e2b9318b626f994b4fcb75a8514ec0715c439466ea18078fe99b6
6
+ metadata.gz: '08739f23905390ab206b19ca7e29ab1284ba4b4f060834bf6c1335123ba9ed5475f77c0c82d1e347630b833eac1961dfbf5a18f5a6b8a72929de83064534ce12'
7
+ data.tar.gz: f3792f4d86690627807c906007fed115dc595b63decda1ffffcdf0be8a5f1651baf27363ccf50188f5f21ce2faff489263d59699ed98eb2a97caf745c43938ca
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudwatch-metrics (1.1.1)
4
+ cloudwatch-metrics (1.1.3)
5
5
  activesupport (~> 7.0)
6
6
  aws-sdk-cloudwatch (~> 1.73)
7
7
  rake (~> 13.0)
@@ -16,16 +16,16 @@ GEM
16
16
  tzinfo (~> 2.0)
17
17
  ast (2.4.2)
18
18
  aws-eventstream (1.2.0)
19
- aws-partitions (1.781.0)
20
- aws-sdk-cloudwatch (1.75.0)
21
- aws-sdk-core (~> 3, >= 3.174.0)
19
+ aws-partitions (1.788.0)
20
+ aws-sdk-cloudwatch (1.78.0)
21
+ aws-sdk-core (~> 3, >= 3.177.0)
22
22
  aws-sigv4 (~> 1.1)
23
- aws-sdk-core (3.175.0)
23
+ aws-sdk-core (3.178.0)
24
24
  aws-eventstream (~> 1, >= 1.0.2)
25
25
  aws-partitions (~> 1, >= 1.651.0)
26
26
  aws-sigv4 (~> 1.5)
27
27
  jmespath (~> 1, >= 1.6.1)
28
- aws-sigv4 (1.5.2)
28
+ aws-sigv4 (1.6.0)
29
29
  aws-eventstream (~> 1, >= 1.0.2)
30
30
  concurrent-ruby (1.2.2)
31
31
  debug (1.8.0)
data/README.md CHANGED
@@ -19,46 +19,11 @@ To create the initializer:
19
19
  rails generate cloudwatch_metrics:initializer
20
20
  ```
21
21
 
22
- The initializer contains descriptions for all available options. The only options you must provide a value for are listed below:
23
-
24
- * **namespace**: This is the default namespace that all metrics will be published to. This should probably match the name of your application or service.
22
+ The initializer contains descriptions for all available options. More detailed descriptions are available in the user guide, linked below. The only option you must provide a value for is `namespace`.
25
23
 
26
24
  ## Usage
27
25
 
28
- Available methods are in the `CloudwatchMetrics` module. For convenience this is aliased to `CW` by default. I.e `CloudwatchMetrics.record(...)` is equivalent to `CW.record(...)`.
29
-
30
- Metrics are recorded using `CW.record` for single data points, or `CW.record_all` for collections of data points. Required and optional parameters for these methods are detailed below.
31
-
32
- ### CW.record Required Parameters
33
-
34
- * `name`: The name of the metric.
35
- * `value`: The value for the single data point being recorded.
36
-
37
- E.g. `CW.record(name: 'search_result_count', value: 25)`
38
-
39
-
40
- `CW.record_all` has a similar method signature, but takes an array of values, and a corresponding array indicating how many times each value occurred during the period.
41
-
42
- ### CW.record_all Required Parameters
43
-
44
- * `name`: The name of the metric.
45
- * `values`: Array of values for the data points being recorded.
46
- * `counts`: Array of numbers indicating the number of times each value occurred during the period. The length of this array should match the length of the `values` array.
47
-
48
- E.g. `CW.record_all(name: 'search_result_count', values: [25, 50, 65], counts: [1, 2, 1])`
49
-
50
- This means that for the `search_result_count` metric we had one search with 25 results, two searches with 50 results, and one search with 65 results.
51
-
52
- ### Optional Parameters
53
-
54
- Both recording methods accept optional parameters, which are detailed below, along with their default values
55
-
56
- * `unit`: The unit of measure for this data point. Units help provide conceptual meaning to your data, but CloudWatch attaches no significance to a unit internally. Common values are `Seconds`, `Kilobytes`, `Percent`, `Count`, `Kilobytes/Second`. Default value is `None`. A full list of available units is available at `CloudwatchMetrics::Units`.
57
- * `namespace`: Override the namespace set in the initializer. Default is `nil`.
58
- * `dimensions`: A hash of name/value pairs that form part of the identity of a metric. Dimensions allow you to group and filter data points for a particular metric. Default is `nil`.
59
- * `timestamp`: The time associated with the data point. The timestamp can be up to two weeks in the past and up to two hours into the future. Default is the current time.
60
-
61
- E.g. `CW.record(name: 'search_result_count', value: 25, unit: CW::COUNT, namespace: 'custom_namespace', dimensions: { group: 'A', subgroup: 'B' }, timestamp: Time.current - 1.day)`
26
+ See [How To: Publish Custom Metrics to CloudWatch](https://www.notion.so/pathccm/How-To-Publish-Custom-Metrics-to-CloudWatch-821be6ddec404b3b827c146a2f5de792#74c9ec588d5841f5bad58b59853054b9) for the user guide.
62
27
 
63
28
  ### Local development
64
29
 
@@ -82,11 +47,14 @@ region = us-west-2
82
47
  output = json
83
48
  ```
84
49
 
85
- ## Cloudwatch Concepts
50
+ ## Changing this gem
51
+
52
+ ### Development
86
53
 
87
- Refer to the [Cloudwatch Documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html) for a general overview of custom metrics in CloudWatch.
54
+ Run `bundle install` to update gemlock file
55
+ Run `rake` to run tests
88
56
 
89
- ## Changing this gem
57
+ ### Deploy new gem
90
58
 
91
59
  If you make changes to this gem you need to do a few things to make those updates available to clients.
92
60
 
@@ -18,7 +18,7 @@ module CloudwatchMetrics
18
18
  end
19
19
 
20
20
  def non_production_prefix
21
- @non_production_prefix ||= 'test-'
21
+ @non_production_prefix ||= 'test/'
22
22
  end
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudwatchMetrics
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.3'
5
5
  end
@@ -92,20 +92,19 @@ module CloudwatchMetrics
92
92
  end
93
93
 
94
94
  # convert key/value hash to format expected by AWS SDK
95
+ # ignore any keys with blank values
95
96
  def map_dimensions(dimensions)
96
97
  combined_dimensions = (configuration.default_dimensions || {}).merge(dimensions || {})
97
98
 
98
99
  mapped_values = []
99
100
  combined_dimensions.keys.each do |key|
100
- mapped_values << {
101
- name: key.to_s,
102
- value: combined_dimensions[key]
103
- }
101
+ mapped_values << {name: key.to_s, value: combined_dimensions[key]} if combined_dimensions[key].present?
104
102
  end
105
103
 
106
104
  mapped_values
107
105
  end
108
106
 
107
+ # handle error by calling configured error handler or logging and raising
109
108
  def handle_error(error)
110
109
  if !configuration.error_handler.nil?
111
110
  configuration.error_handler.call(error)
@@ -116,6 +115,7 @@ module CloudwatchMetrics
116
115
  raise CloudwatchMetrics::Error, error.message
117
116
  end
118
117
 
118
+ # get namespace from configuration or use provided value and apply non-production prefix if applicable
119
119
  def full_namespace(provided_namespace)
120
120
  constructed_namespace = provided_namespace || configuration.namespace
121
121
  raise CloudwatchMetrics::Error, 'Namespace must be provided' if constructed_namespace.blank?
@@ -35,8 +35,8 @@ 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. If empty or nil no prefix will be applied. Defaults to 'test-'.
39
- # config.non_production_prefix = 'test-'
38
+ # metrics with test data. If empty or nil no prefix will be applied. Defaults to 'test/'.
39
+ # config.non_production_prefix = 'test/'
40
40
 
41
41
  # This is an optional configuration to set an error handler proc.
42
42
  # If not set the default error handler will log the error
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.1
4
+ version: 1.1.3
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-21 00:00:00.000000000 Z
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport