cloudwatch-metrics 0.1.21 → 0.1.23

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: 41179d4e917327cef33e11238f08f5db64e3273a9d604796c32dc62f7d9b7e17
4
- data.tar.gz: c6c41cf350ace1d9f30a7d268c43c114e4dfa9ee2a61113e922e2b2c0107bcfe
3
+ metadata.gz: f4b6ce5478577632da1a4a4abc67a506391caeb38a0378524bb9c805f6f98317
4
+ data.tar.gz: 9bdf48c8c1bab49ebfd2b1a25a73b0d9efc276e161dbdcb5eadd616d4d2af205
5
5
  SHA512:
6
- metadata.gz: 441baeab14d2d0224b9fe60b1ab11d39384fdbe737fc12df2928a8e7b23d9d5a521b1c89c1da11302e517c4fd6b0b8030d04a6e4e7a2e18ae922dcf7093487f6
7
- data.tar.gz: e828b703ae6eae50242e9893e1afdf42e9414adac61b2077f22f5f5a488a6fe7bfb4665d0e985c676c2348499301a961ca8c313fe74423467b5dbba1fd0f7456
6
+ metadata.gz: b95e7e22e300c32956f4dd5dff3a462eba274f84a4e35c11ad60ba7cfef1cb73512cc1c0aff1f96eb4063f3d96850e9441f1fd5e59f2290469e8897b1b4c1354
7
+ data.tar.gz: 8d30a5c23eee241f0c3ab6653db4079c7c7365efa358d80e4c43fc275f48522f74fc4cfd4be8508a80724a24b4d74e56adf229c388c2cfc28865d3c0d1ec66e3
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.21
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Puckett
@@ -11,88 +11,60 @@ cert_chain: []
11
11
  date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aws-sdk-cloudwatch
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.73'
19
+ version: '7.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.73'
26
+ version: '7.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '13.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
28
+ name: aws-sdk-cloudwatch
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '3.0'
33
+ version: '1.73'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '3.0'
40
+ version: '1.73'
55
41
  - !ruby/object:Gem::Dependency
56
- name: rubocop
42
+ name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.21'
47
+ version: '13.0'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1.21'
54
+ version: '13.0'
69
55
  description:
70
56
  email:
71
57
  - puckett.seth@gmail.com
72
58
  executables: []
73
59
  extensions: []
74
60
  extra_rdoc_files: []
75
- files:
76
- - ".rspec"
77
- - ".rubocop.yml"
78
- - ".rubocop_strict.yml"
79
- - Gemfile
80
- - Gemfile.lock
81
- - README.md
82
- - Rakefile
83
- - bin/console
84
- - bin/setup
85
- - lib/cloudwatch_metrics.rb
86
- - lib/cloudwatch_metrics/configuration.rb
87
- - lib/cloudwatch_metrics/constants.rb
88
- - lib/cloudwatch_metrics/version.rb
89
- - lib/generators/cloudwatch_metrics/initializer_generator.rb
90
- - lib/generators/cloudwatch_metrics/templates/cloudwatch_metrics.rb
61
+ files: []
91
62
  homepage: https://github.com/pathccm/cloudwatch_metrics
92
63
  licenses: []
93
64
  metadata:
94
65
  homepage_uri: https://github.com/pathccm/cloudwatch_metrics
95
66
  source_code_uri: https://github.com/pathccm/cloudwatch_metrics
67
+ rubygems_mfa_required: 'true'
96
68
  post_install_message:
97
69
  rdoc_options: []
98
70
  require_paths:
@@ -101,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
73
  requirements:
102
74
  - - ">="
103
75
  - !ruby/object:Gem::Version
104
- version: 2.6.0
76
+ version: '3.0'
105
77
  required_rubygems_version: !ruby/object:Gem::Requirement
106
78
  requirements:
107
79
  - - ">="
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,339 +0,0 @@
1
- inherit_from:
2
- - .rubocop_strict.yml
3
-
4
- inherit_mode:
5
- merge:
6
- - Exclude
7
-
8
- require:
9
- - rubocop-rspec
10
- - rubocop-performance
11
- - rubocop-rails
12
-
13
- ## For Reference:
14
- ## Rubocop docs: https://docs.rubocop.org/
15
- ## Ruby Style Guide: https://rubystyle.guide/
16
- ## Rails Style Guide: https://rails.rubystyle.guide/
17
- ## RSpec Style Guide: https://rspec.rubystyle.guide/
18
-
19
- AllCops:
20
- TargetRubyVersion: 3.0.3
21
- SuggestExtensions: false
22
- NewCops: enable
23
- Exclude:
24
- - bin/**/*
25
- - config/**/*
26
- - db/seeds/**/*
27
- - db/*
28
- - node_modules/**/*
29
- - vendor/**/*
30
- - tmp/**/*
31
-
32
- Layout/SpaceInsideHashLiteralBraces:
33
- Enabled: true
34
- EnforcedStyle: no_space
35
- EnforcedStyleForEmptyBraces: no_space
36
-
37
- Layout/MultilineMethodCallIndentation:
38
- Enabled: true
39
- EnforcedStyle: indented
40
-
41
- Layout/ArrayAlignment:
42
- Enabled: true
43
- EnforcedStyle: with_fixed_indentation
44
-
45
- Layout/FirstHashElementIndentation:
46
- Enabled: true
47
- EnforcedStyle: consistent
48
-
49
- Style/NegatedIf:
50
- Enabled: true
51
- EnforcedStyle: postfix
52
-
53
- Layout/FirstArgumentIndentation:
54
- Enabled: true
55
- EnforcedStyle: consistent
56
-
57
- Layout/MultilineOperationIndentation:
58
- Enabled: true
59
- EnforcedStyle: indented
60
-
61
- Layout/FirstArrayElementIndentation:
62
- Enabled: true
63
- EnforcedStyle: consistent
64
-
65
- Style/HashSyntax:
66
- Enabled: true
67
- EnforcedStyle: ruby19_no_mixed_keys
68
-
69
- Style/EmptyMethod:
70
- Enabled: true
71
- EnforcedStyle: expanded
72
-
73
- Style/RescueModifier:
74
- Enabled: true
75
- Exclude:
76
- - spec/**/*
77
-
78
- Rails/Output:
79
- Enabled: true
80
- Exclude:
81
- - lib/**/*
82
- - app/services/tasks/*
83
-
84
- Rails/UnknownEnv:
85
- Enabled: true
86
- Environments:
87
- - production
88
- - staging
89
- - test
90
- - development
91
-
92
- Metrics/BlockNesting:
93
- Enabled: true
94
- Max: 3
95
-
96
- # Default Max: 10
97
- Metrics/MethodLength:
98
- Max: 20
99
- CountAsOne: ['array', 'hash']
100
-
101
- Metrics/ModuleLength:
102
- Enabled: true
103
- Max: 100
104
- CountAsOne: ['array', 'hash']
105
-
106
- Metrics/PerceivedComplexity:
107
- Enabled: true
108
- Max: 16
109
-
110
- Metrics/ParameterLists:
111
- Enabled: true
112
- Max: 8
113
-
114
- Style/Documentation:
115
- Enabled: false
116
-
117
- # Leave disabled in favor of Perceived/Complexity
118
- Metrics/AbcSize:
119
- Enabled: false
120
-
121
- Style/ClassAndModuleChildren:
122
- Enabled: false
123
-
124
- Style/IfUnlessModifier:
125
- Enabled: false
126
-
127
- Naming/RescuedExceptionsVariableName:
128
- Enabled: false
129
-
130
- Style/InverseMethods:
131
- Enabled: false
132
-
133
- Style/StringConcatenation:
134
- Enabled: false
135
-
136
- Style/HashEachMethods:
137
- Enabled: false
138
-
139
- Style/CaseLikeIf:
140
- Enabled: false
141
-
142
- # Leave disabled in favor of PerceivedComplexity
143
- Metrics/CyclomaticComplexity:
144
- Enabled: false
145
-
146
- Style/Next:
147
- Enabled: false
148
-
149
- Layout/EmptyLineAfterGuardClause:
150
- Enabled: false
151
-
152
- Style/HashAsLastArrayItem:
153
- Enabled: false
154
-
155
- Lint/ShadowingOuterLocalVariable:
156
- Enabled: false
157
-
158
- Naming/AccessorMethodName:
159
- Enabled: false
160
-
161
- Style/IfWithBooleanLiteralBranches:
162
- Enabled: false
163
-
164
- Metrics/BlockLength:
165
- Enabled: false
166
-
167
- Style/NumericPredicate:
168
- Enabled: false
169
-
170
- Style/SoleNestedConditional:
171
- Enabled: false
172
-
173
- Style/GuardClause:
174
- Enabled: false
175
-
176
- Style/SymbolArray:
177
- Enabled: false
178
-
179
- Style/WordArray:
180
- Enabled: false
181
-
182
- Naming/VariableNumber:
183
- Enabled: false
184
-
185
- Naming/MethodParameterName:
186
- Enabled: false
187
-
188
- Lint/DuplicateBranch:
189
- Enabled: false
190
-
191
- Style/MultilineTernaryOperator:
192
- Enabled: false
193
-
194
- Naming/MemoizedInstanceVariableName:
195
- Enabled: false
196
-
197
- Style/SymbolProc:
198
- Enabled: false
199
-
200
- Lint/UselessAccessModifier:
201
- Enabled: false
202
-
203
- Lint/UselessMethodDefinition:
204
- Enabled: false
205
-
206
- Lint/EmptyBlock:
207
- Enabled: false
208
-
209
- Style/CaseEquality:
210
- Enabled: false
211
-
212
- Style/ExplicitBlockArgument:
213
- Enabled: false
214
-
215
- Lint/TripleQuotes:
216
- Enabled: false
217
-
218
- Style/ZeroLengthPredicate:
219
- Enabled: false
220
-
221
- Style/StringChars:
222
- Enabled: false
223
-
224
- Performance/RedundantSplitRegexpArgument:
225
- Enabled: false
226
-
227
- Style/OptionalBooleanParameter:
228
- Enabled: false
229
-
230
- Style/RedundantArgument:
231
- Enabled: false
232
-
233
- Style/MutableConstant:
234
- Enabled: false
235
-
236
- Naming/PredicateName:
237
- Enabled: false
238
-
239
- Lint/UnusedBlockArgument:
240
- Enabled: false
241
-
242
- Style/RaiseArgs:
243
- Enabled: false
244
-
245
- Style/MultilineBlockChain:
246
- Enabled: false
247
-
248
- Performance/Sum:
249
- Enabled: false
250
-
251
- Lint/UnexpectedBlockArity:
252
- Enabled: false
253
-
254
- Lint/SymbolConversion:
255
- Enabled: false
256
-
257
- Performance/CollectionLiteralInLoop:
258
- Enabled: false
259
-
260
- Style/FormatString:
261
- Enabled: false
262
-
263
- Style/FormatStringToken:
264
- Enabled: false
265
-
266
- Lint/MissingSuper:
267
- Enabled: false
268
-
269
- Style/NumericLiterals:
270
- Enabled: false
271
-
272
- Style/RegexpLiteral:
273
- Enabled: false
274
-
275
- Style/PreferredHashMethods:
276
- Enabled: false
277
-
278
- Lint/EmptyClass:
279
- Enabled: false
280
-
281
- Style/WhileUntilModifier:
282
- Enabled: false
283
-
284
- Lint/DisjunctiveAssignmentInConstructor:
285
- Enabled: false
286
-
287
- Style/FloatDivision:
288
- Enabled: false
289
-
290
- Lint/ToJSON:
291
- Enabled: false
292
-
293
- Performance/Casecmp:
294
- Enabled: false
295
-
296
- Style/CommentAnnotation:
297
- Enabled: false
298
-
299
- Lint/EmptyFile:
300
- Enabled: false
301
-
302
- Style/AccessorGrouping:
303
- Enabled: false
304
-
305
- Naming/MethodName:
306
- Enabled: false
307
-
308
- Style/DoubleNegation:
309
- Enabled: false
310
-
311
- Lint/AmbiguousBlockAssociation:
312
- Enabled: false
313
-
314
- Performance/TimesMap:
315
- Enabled: false
316
-
317
- Style/ExpandPathArguments:
318
- Enabled: false
319
-
320
- Style/Lambda:
321
- Enabled: false
322
-
323
- Style/RedundantSelfAssignment:
324
- Enabled: false
325
-
326
- Layout/EmptyLinesAroundAttributeAccessor:
327
- Enabled: false
328
-
329
- Style/NegatedIfElseCondition:
330
- Enabled: false
331
-
332
- Lint/ImplicitStringConcatenation:
333
- Enabled: false
334
-
335
- Rails/RenderInline:
336
- Enabled: false
337
-
338
- Rails/LexicallyScopedActionFilter:
339
- Enabled: false
data/.rubocop_strict.yml DELETED
@@ -1,23 +0,0 @@
1
- # Inspiration: https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard
2
- # There are a handful of cops that should be applied to all
3
- # files always regardless of anything.
4
- # These are those cops.
5
- Lint/Debugger: # don't leave binding.pry
6
- Enabled: true
7
- Exclude: []
8
-
9
- RSpec/Focus: # run ALL tests on CI
10
- Enabled: true
11
- Exclude: []
12
-
13
- Rails/Output: # Don't leave puts-debugging
14
- Enabled: true
15
- Exclude: []
16
-
17
- Rails/FindEach: # each could severely affect the performance, use find_each
18
- Enabled: true
19
- Exclude: []
20
-
21
- Rails/UniqBeforePluck: # uniq.pluck and not pluck.uniq
22
- Enabled: true
23
- Exclude: []
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,71 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cloudwatch-metrics (0.1.11)
5
- aws-sdk-cloudwatch (~> 1.73)
6
- rake (~> 13.0)
7
- rspec (~> 3.0)
8
- rubocop (~> 1.21)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- ast (2.4.2)
14
- aws-eventstream (1.2.0)
15
- aws-partitions (1.776.0)
16
- aws-sdk-cloudwatch (1.74.0)
17
- aws-sdk-core (~> 3, >= 3.174.0)
18
- aws-sigv4 (~> 1.1)
19
- aws-sdk-core (3.174.0)
20
- aws-eventstream (~> 1, >= 1.0.2)
21
- aws-partitions (~> 1, >= 1.651.0)
22
- aws-sigv4 (~> 1.5)
23
- jmespath (~> 1, >= 1.6.1)
24
- aws-sigv4 (1.5.2)
25
- aws-eventstream (~> 1, >= 1.0.2)
26
- diff-lcs (1.5.0)
27
- jmespath (1.6.2)
28
- json (2.6.3)
29
- parallel (1.23.0)
30
- parser (3.2.2.1)
31
- ast (~> 2.4.1)
32
- rainbow (3.1.1)
33
- rake (13.0.6)
34
- regexp_parser (2.8.0)
35
- rexml (3.2.5)
36
- rspec (3.12.0)
37
- rspec-core (~> 3.12.0)
38
- rspec-expectations (~> 3.12.0)
39
- rspec-mocks (~> 3.12.0)
40
- rspec-core (3.12.2)
41
- rspec-support (~> 3.12.0)
42
- rspec-expectations (3.12.3)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.12.0)
45
- rspec-mocks (3.12.5)
46
- diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.12.0)
48
- rspec-support (3.12.0)
49
- rubocop (1.52.0)
50
- json (~> 2.3)
51
- parallel (~> 1.10)
52
- parser (>= 3.2.0.0)
53
- rainbow (>= 2.2.2, < 4.0)
54
- regexp_parser (>= 1.8, < 3.0)
55
- rexml (>= 3.2.5, < 4.0)
56
- rubocop-ast (>= 1.28.0, < 2.0)
57
- ruby-progressbar (~> 1.7)
58
- unicode-display_width (>= 2.4.0, < 3.0)
59
- rubocop-ast (1.29.0)
60
- parser (>= 3.2.1.0)
61
- ruby-progressbar (1.13.0)
62
- unicode-display_width (2.4.2)
63
-
64
- PLATFORMS
65
- arm64-darwin-22
66
-
67
- DEPENDENCIES
68
- cloudwatch-metrics!
69
-
70
- BUNDLED WITH
71
- 2.2.32
data/README.md DELETED
@@ -1,97 +0,0 @@
1
- # CloudwatchMetrics
2
-
3
- `CloudwatchMetrics` is a Ruby gem for writing custom metrics to AWS Cloudwatch.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
- ```ruby
9
- gem 'cloudwatch_metrics'
10
- ```
11
-
12
- And then execute:
13
- ```
14
- bundle install
15
- ```
16
-
17
- To create the initializer:
18
- ```
19
- rails generate cloudwatch_metrics:initializer
20
- ```
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.
25
-
26
- ## Usage
27
-
28
- Available methods are in the `CloudwatchMetrics` module. For convenience this is aliased to `CW` by default.
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
- ### Optional Parameters
51
-
52
- Both recording methods accept optional parameters, which are detailed below, along with their default values
53
-
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
- * `namespace`: Override the namespace set in the initializer. 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 for a particular metric. Default is `nil`.
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
-
59
- 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)`
60
-
61
- ### Local development
62
-
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.
64
-
65
- ### AWS Credentials
66
-
67
- See [HOWTO Assume AWS role](https://docs.google.com/document/d/1NCXtlhddpJCttBPs2V4mv3J59V0C3ShTzaoSidBAVTU/edit#heading=h.kr4pxvf3gqqt) for info about setting up AWS credential locally. You can read more about AWS SDK configuration in the [AWS docs](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html).
68
-
69
- The short version: Create a file `~/.aws/config` and add your access keys there:
70
- ```
71
- [default]
72
- aws_access_key_id = $AWS_ACCESS_KEY_ID
73
- aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
74
- ```
75
-
76
- You'll also want an `~/.aws/config` file to set the default region
77
- ```
78
- [default]
79
- region = us-west-2
80
- output = json
81
- ```
82
-
83
- ## Cloudwatch Concepts
84
-
85
- 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.
86
-
87
- ## Changing this gem
88
-
89
- If you make changes to this gem you need to do a few things to make those updates available to clients.
90
-
91
- **Prerequisites**: You will need an account on [rubygems.org](https://rubygems.org/) and you will need to be added as an owner of this gem. Talk to Seth for this. ([Managing Owners](https://guides.rubygems.org/managing-owners-using-ui/))
92
-
93
- 1. Bump the version in `lib/cloudwatch_metrics/version.rb`
94
- 2. Build the updated gem with `gem build cloudwatch_metrics.gemspec`
95
- 3. Push the updated to gem to rubygems with `gem push ./cloudwatch-metrics-[VERSION].gem`
96
-
97
- When the change has been published clients can update to the latest version with `bundle update cloudwatch-metrics`.
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "cloudwatch_metrics"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CloudwatchMetrics
4
- class Configuration
5
- attr_accessor :namespace, :region
6
- attr_writer :no_cw_alias, :publish_environments, :logger
7
-
8
- def no_cw_alias
9
- @no_cw_alias ||= false
10
- end
11
-
12
- def publish_environments
13
- @publish_environments ||= %w[production]
14
- end
15
-
16
- def logger
17
- @logger ||= Logger.new(STDOUT)
18
- end
19
- end
20
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CloudwatchMetrics
4
- SECONDS = 'Seconds'
5
- MICROSECONDS = 'Microseconds'
6
- MILLISECONDS = 'Milliseconds'
7
- BYTES = 'Bytes'
8
- KILOBYTES = 'Kilobytes'
9
- MEGABYTES = 'Megabytes'
10
- GIGABYTES = 'Gigabytes'
11
- TERABYTES = 'Terabytes'
12
- BITS = 'Bits'
13
- KILOBITS = 'Kilobits'
14
- MEGABITS = 'Megabits'
15
- GIGABITS = 'Gigabits'
16
- TERABITS = 'Terabits'
17
- PERCENT = 'Percent'
18
- COUNT = 'Count'
19
- BYTES_PER_SECOND = 'Bytes/Second'
20
- KILOBYTES_PER_SECOND = 'Kilobytes/Second'
21
- MEGABYTES_PER_SECOND = 'Megabytes/Second'
22
- GIGABYTES_PER_SECOND = 'Gigabytes/Second'
23
- TERABYTES_PER_SECOND = 'Terabytes/Second'
24
- BITS_PER_SECOND = 'Bits/Second'
25
- KILOBITS_PER_SECOND = 'Kilobits/Second'
26
- MEGABITS_PER_SECOND = 'Megabits/Second'
27
- GIGABITS_PER_SECOND = 'Gigabits/Second'
28
- TERABITS_PER_SECOND = 'Terabits/Second'
29
- COUNT_PER_SECOND = 'Count/Second'
30
- NONE = 'None'
31
-
32
- UNITS = [
33
- SECONDS, MICROSECONDS, MILLISECONDS, BYTES, KILOBYTES, MEGABYTES, GIGABYTES, TERABYTES, BITS, KILOBITS,
34
- MEGABITS, GIGABITS, TERABITS, PERCENT, COUNT, BYTES_PER_SECOND, KILOBYTES_PER_SECOND, MEGABYTES_PER_SECOND,
35
- GIGABYTES_PER_SECOND, TERABYTES_PER_SECOND, BITS_PER_SECOND, KILOBITS_PER_SECOND, MEGABITS_PER_SECOND,
36
- GIGABITS_PER_SECOND, TERABITS_PER_SECOND, COUNT_PER_SECOND, NONE
37
- ]
38
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CloudwatchMetrics
4
- VERSION = '0.1.21'
5
- end
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'cloudwatch_metrics/configuration'
4
- require_relative 'cloudwatch_metrics/constants'
5
-
6
- # Posts custom metrics to AWS CloudWatch
7
- module CloudwatchMetrics
8
- class Error < StandardError; end
9
-
10
- class << self
11
- def configuration
12
- @configuration ||= Configuration.new
13
- end
14
-
15
- def configure
16
- yield(configuration)
17
- end
18
-
19
- def record(
20
- name:, value:, unit: nil, namespace: configuration.namespace, dimensions: nil, timestamp: nil
21
- )
22
- metric_data = [{
23
- metric_name: name,
24
- value: value,
25
- unit: unit,
26
- dimensions: map_dimensions(dimensions),
27
- timestamp: timestamp
28
- }]
29
- put_data(namespace: namespace, metric_data: metric_data)
30
- end
31
-
32
- def record_all(
33
- name:, values:, counts:, unit: nil, namespace: configuration.namespace, dimensions: nil, timestamp: nil
34
- )
35
- metric_data = [{
36
- metric_name: name,
37
- values: values,
38
- counts: counts,
39
- unit: unit,
40
- dimensions: map_dimensions(dimensions),
41
- timestamp: timestamp
42
- }]
43
- put_data(namespace: namespace, metric_data: metric_data)
44
- end
45
-
46
- private
47
-
48
- def put_data(namespace:, metric_data:)
49
- if configuration.publish_environments.include?(environment)
50
- cloudwatch_client.put_metric_data({namespace: namespace, metric_data: metric_data})
51
- else
52
- configuration.logger.info("CloudwatchMetrics (#{namespace}): #{metric_data}")
53
- end
54
-
55
- nil
56
- rescue StandardError => e
57
- configuration.logger.error("CloudwatchMetrics error: #{e.message}")
58
- raise CloudwatchMetrics::Error, e.message
59
- end
60
-
61
- def cloudwatch_client
62
- return @cloudwatch_client unless @cloudwatch_client.nil?
63
-
64
- @cloudwatch_client = if !configuration.region.nil?
65
- Aws::CloudWatch::Client.new(region: configuration.region)
66
- else
67
- Aws::CloudWatch::Client.new
68
- end
69
- end
70
-
71
- def environment
72
- ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
73
- end
74
-
75
- # convert key/value hash to format expected by AWS SDK
76
- def map_dimensions(dimensions)
77
- return [] if dimensions.nil?
78
-
79
- mapped_values = []
80
- dimensions.keys.each do |key|
81
- mapped_values << {
82
- name: key,
83
- value: dimensions[key]
84
- }
85
- end
86
-
87
- mapped_values
88
- end
89
- end
90
- end
91
-
92
- CW = CloudwatchMetrics unless CloudwatchMetrics.configuration.no_cw_alias
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CloudwatchMetrics
4
- module Generators
5
- class InitializerGenerator < Rails::Generators::Base
6
- source_root File.expand_path('templates', __dir__)
7
-
8
- def copy_initializer_file
9
- copy_file 'cloudwatch_metrics.rb', 'config/initializers/cloudwatch_metrics.rb'
10
- end
11
- end
12
- end
13
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'cloudwatch_metrics'
4
-
5
- CloudwatchMetrics.configure do |config|
6
- # This is the default namespace that all metrics will be published to.
7
- # This should probably match the name of your application or service.
8
- config.namespace = 'APPLICATION_NAME'
9
-
10
- # This is an optional configuration that will allow you to disable the
11
- # `CW` alias. This is useful if you have a constant named `CW` that
12
- # conflicts with the alias. Default is `false`.
13
- # config.no_cw_alias = true
14
-
15
- # This is an optional configuration to set the region that
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 configuration.
18
- # config.region = 'us-east-1'
19
-
20
- # By default metrics will only be published in the production environment.
21
- # In all other environments metrics will be logged.
22
- # You can override this behavior by specifying an array of environments
23
- # that you want to publish metrics in.
24
- # config.publish_environments = %w[production development]
25
-
26
- # This is an optional configuration to set the logger that
27
- # the metrics will be logged to. Defaults to `Logger.new(STDOUT)`.
28
- # For rails applications you can set this to `Rails.logger`.
29
- # config.logger = Rails.logger
30
- end