cloudwatch-metrics 0.1.10 → 0.1.12

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: e91c58bffeee53bb5b3272031f522133f2b3ec67ad0e1c75f81193026a4d5037
4
- data.tar.gz: 742fa5b4f52be3918d782f390babb0f0c09fe819842aafbc82807d0df4d43790
3
+ metadata.gz: acc825c244c5b16fcd792fb39fe89785710cdcc5aa08c43cf082cda2200fada4
4
+ data.tar.gz: eef5bd9df19b6d13dcf8a2ec4d0b0dcbc1fab97d4822854408031aac0cb9e01b
5
5
  SHA512:
6
- metadata.gz: e0293109370d02b2ceb4d4395536336719f71bf99c974b470f2c359b134d8ec2b14432f1840da8f99cb4bac03eb51590445fe9e449aa942d79403f7f05cc5307
7
- data.tar.gz: c7290bd824d12277457f388de3541926828f7cde2dc4441b74028b2f81dd9802cd965caa1482d82e0ef12d1e3ab1ef2c3cd61fc54668a58446d3a4de934257df
6
+ metadata.gz: 2bd61f9092d0619f54c5f47056372511e0735ad75b0ce936ed9b4393d2d636734d10a95a5d1774111aa1efb60029c950d0982b43e72a5d0fa2e4da9c41645510
7
+ data.tar.gz: e92a0955168e84c4d5eb6cc3c586b647ef0acdf5c99457ada45312cad53ab088be05115e372bdd8e09cc178562f0194b495c7e1d8019d98edcb5b5b86a0f7a00
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudwatch-metrics (0.1.7)
4
+ cloudwatch-metrics (0.1.11)
5
5
  aws-sdk-cloudwatch (~> 1.73)
6
6
  rake (~> 13.0)
7
7
  rspec (~> 3.0)
data/README.md CHANGED
@@ -59,4 +59,16 @@ Both reporting methods accept optional parameters, which are detailed below, alo
59
59
 
60
60
  ## Cloudwatch Concepts
61
61
 
62
- 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.
62
+ 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.
63
+
64
+ ## Changing this gem
65
+
66
+ If you make changes to this gem you need to do a few things to make those updates available to clients.
67
+
68
+ **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/))
69
+
70
+ 1. Bump the version in `lib/cloudwatch_metrics/version.rb`
71
+ 2. Build the updated gem with `gem build cloudwatch_metrics.gemspec`
72
+ 3. Push the updated to gem to rubygems with `gem push ./cloudwatch-metrics-[VERSION].gem`
73
+
74
+ When the change has been published clients can update to the latest version with `bundle update cloudwatch-metrics`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CloudwatchMetrics
4
4
  class Configuration
5
- attr_accessor :namespace
5
+ attr_accessor :namespace, :region
6
6
  attr_writer :no_cw_alias
7
7
 
8
8
  def no_cw_alias
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudwatchMetrics
4
- VERSION = "0.1.10"
4
+ VERSION = '0.1.12'
5
5
  end
@@ -7,18 +7,10 @@ module CloudwatchMetrics
7
7
  class Error < StandardError; end
8
8
 
9
9
  class << self
10
- def configuration
11
- @configuration ||= Configuration.new
12
- end
13
-
14
10
  def configure
15
11
  yield(configuration)
16
12
  end
17
13
 
18
- def hi
19
- puts "Hello, #{configuration.namespace}"
20
- end
21
-
22
14
  def record(
23
15
  metric_name:, value:, unit: nil, namespace: configuration.namespace, dimensions: [], timestamp: nil
24
16
  )
@@ -48,8 +40,16 @@ module CloudwatchMetrics
48
40
 
49
41
  private
50
42
 
43
+ def configuration
44
+ @configuration ||= Configuration.new
45
+ end
46
+
47
+ def cloudwatch_client
48
+ @cloudwatch_client ||= Aws::CloudWatch::Client.new(region: configuration.region)
49
+ end
50
+
51
51
  def put_data(namespace:, metric_data:)
52
- resp = @cloudwatch_client.put_metric_data({
52
+ resp = cloudwatch_client.put_metric_data({
53
53
  namespace: namespace,
54
54
  metric_data: metric_data
55
55
  })
@@ -57,4 +57,4 @@ module CloudwatchMetrics
57
57
  end
58
58
  end
59
59
 
60
- CW = CloudwatchMetrics unless configuration.no_cw_alias
60
+ CW = CloudwatchMetrics unless CloudwatchMetrics.configuration.no_cw_alias
@@ -11,4 +11,9 @@ CloudwatchMetrics.configure do |config|
11
11
  # `CW` alias. This is useful if you have a constant named `CW` that
12
12
  # conflicts with the alias. Default is `false`.
13
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 credentials.
18
+ # config.region = 'us-east-1'
14
19
  end
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.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Puckett