cloudwatch-metrics 0.1.15 → 0.1.16

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: 1dff409be424bcafe2081ebe6583808b9577f957db434dcf6d0101f4e61c8eb9
4
- data.tar.gz: bc45bed975955dc25846b8a427f8ed28b62f26f4910a8fef8262374ccd21eede
3
+ metadata.gz: 97790dd4bec2f067aeca87ba8aabaa580fbb98f793125258d4bdb53fea42da5d
4
+ data.tar.gz: 6ea60c0395cd756541de4c87bf81b74fd06f26f467be9bdd21d3cb2fb52381cd
5
5
  SHA512:
6
- metadata.gz: c63953bc1565b6aa922d8521067193d25c680667a09a1361dd5ef8dfaacdbbf31acf50ea0b11f552355372146a27dad2df59b6314f3cb70d330e538c084c8740
7
- data.tar.gz: 4c93c5b6b9a38d6a570e86c271d0855bea2321b6c3474a9231119bfa3798a6e8af3a4158604738fc6e0cfc7c6cf681c1bdcd26ab7fe62494def64beeb639eea0
6
+ metadata.gz: 8767e36b91438b6178ebe96cac9a1a712629279afa37b20dd4624ae46319d6279544b3d63dc537fdf44272d286c790f9eb6f40b31e013391ace747e96b7c86bf
7
+ data.tar.gz: 16fb72d30d8f932f17e47281eee1c23d234a93fb222426c3b7423b9fb4fb30bff8746f366c619b7ac1d1a4f07e551684dfc05c1eea4d30864e04cdad0fdf3d71
data/README.md CHANGED
@@ -53,9 +53,11 @@ Both reporting methods accept optional parameters, which are detailed below, alo
53
53
 
54
54
  * `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`.
55
55
  * `namespace`: Override the namespace set in the initializer. Default is `nil`
56
- * `dimensions`: An array of name/value pairs that form part of the identity of a metric. Dimensions allow you to group and filter data points within a particular metric. Default is `nil`.
56
+ * `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 within a particular metric. Default is `nil`.
57
57
  * `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.
58
58
 
59
+ E.g. `CW.report(metric_name: 'search_result_count', value: 25, unit: CW.COUNT, namespace: 'custom_namespace', dimensions: { group: 'A', subgroup: 'B' }, timeStamp: Time.current - 1.day)`
60
+
59
61
  ### Local development
60
62
 
61
63
  By default, `CloudWatchMetrics` only publishes to Cloudwatch in the production environment. In other environments it will write to the configured logger. These settings can be changed in the initializer.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudwatchMetrics
4
- VERSION = '0.1.15'
4
+ VERSION = '0.1.16'
5
5
  end
@@ -22,7 +22,7 @@ module CloudwatchMetrics
22
22
  metric_name: metric_name,
23
23
  value: value,
24
24
  unit: unit,
25
- dimensions: dimensions,
25
+ dimensions: map_dimensions(dimensions),
26
26
  timestamp: timestamp
27
27
  }]
28
28
  put_data(namespace: namespace, metric_data: metric_data)
@@ -36,7 +36,7 @@ module CloudwatchMetrics
36
36
  values: values,
37
37
  counts: counts,
38
38
  unit: unit,
39
- dimensions: dimensions,
39
+ dimensions: map_dimensions(dimensions),
40
40
  timestamp: timestamp
41
41
  }]
42
42
  put_data(namespace: namespace, metric_data: metric_data)
@@ -70,6 +70,21 @@ module CloudwatchMetrics
70
70
  def environment
71
71
  ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
72
72
  end
73
+
74
+ # convert key/value hash to format expected by AWS SDK
75
+ def map_dimensions(dimensions)
76
+ return [] if dimensions.nil?
77
+
78
+ mapped_values = []
79
+ dimensions.keys.each do |key|
80
+ mapped_values << {
81
+ name: key,
82
+ value: dimensions[key]
83
+ }
84
+ end
85
+
86
+ mapped_values
87
+ end
73
88
  end
74
89
  end
75
90
 
@@ -14,14 +14,14 @@ CloudwatchMetrics.configure do |config|
14
14
 
15
15
  # This is an optional configuration to set the region that
16
16
  # the metrics will be published to. This is useful if you want to publish
17
- # to a region other than the default region for your AWS credentials.
17
+ # to a region other than the default region for your AWS configuration.
18
18
  # config.region = 'us-east-1'
19
19
 
20
20
  # By default metrics will only be published in the production environment.
21
21
  # In all other environments metrics will be logged.
22
22
  # You can override this behavior by specifying an array of environments
23
23
  # that you want to publish metrics in.
24
- # config.publish_environments = %w[production staging]
24
+ # config.publish_environments = %w[production development]
25
25
 
26
26
  # This is an optional configuration to set the logger that
27
27
  # the metrics will be logged to. Defaults to `Logger.new(STDOUT)`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudwatch-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Puckett