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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97790dd4bec2f067aeca87ba8aabaa580fbb98f793125258d4bdb53fea42da5d
|
4
|
+
data.tar.gz: 6ea60c0395cd756541de4c87bf81b74fd06f26f467be9bdd21d3cb2fb52381cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`:
|
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.
|
data/lib/cloudwatch_metrics.rb
CHANGED
@@ -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
|
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
|
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)`.
|