sidewatch 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1bfbd1570fe2102b145f87c85c38204766ee07e
4
- data.tar.gz: 5ebf2ba6b7513a5ed9ca800e5a23eefe303c226f
3
+ metadata.gz: 53c84c0248846f6f5a57673e78d31223408f9699
4
+ data.tar.gz: 668241adc7830ef651272445ae8597767f01e80f
5
5
  SHA512:
6
- metadata.gz: 114f60848612756f2eee7edf48931bb0d1c5021e983114e6d9d8ceaa5d70c2a20158331a305c3a4868a7a35e824194a334e84453463a2ce20a5a81c0b445e883
7
- data.tar.gz: 7a65e525f6bbfa6946d2e5ef16cf618ade8caef0f861774a354c25487d775393d261fa1d8045121c00a608d4888f20e0ccce3b569a2df562dd2400dffa738e22
6
+ metadata.gz: 5d8838dd0d012f9745702dbcac17bcbe6f21b70cedf75a4a85feddad9d595856eed089d45a851da9bb27080e52eae3e3cca019858b147574dbdbd48618c495eb
7
+ data.tar.gz: 561da07d5a8d69f0b047ffa485f3b941e92d196dc62103e238644d91387b6fd98700d808c5c24f9511146e9376f62e8842bf298c7f1cead8fc2e979edf70eb38
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  *.gem
2
2
  *.log
3
- *.yml
4
3
  *.rbc
5
4
  .bundle
6
5
  .env
@@ -14,6 +13,7 @@ doc/
14
13
  lib/bundler/man
15
14
  pkg
16
15
  rdoc
16
+ sidewatch.yml
17
17
  spec/reports
18
18
  test/tmp
19
19
  test/version_tmp
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1.0
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ 0.0.4
4
+ -----------
5
+ - Upload metrics to CloudWatch in batches of max. 20 entries [#1]
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Sidewatch
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/sidewatch.svg)](https://rubygems.org/gems/sidewatch)
4
+ [![Build Status](https://travis-ci.org/travelmob/sidewatch.svg)](https://travis-ci.org/travelmob/sidewatch)
5
+
3
6
  Sidewatch uploads Sidekiq metrics to AWS CloudWatch in regular intervals.
4
7
 
5
8
  ## Installation
@@ -20,11 +23,40 @@ Or install it yourself as:
20
23
 
21
24
  To start sidewatch as a daemon process in the background run
22
25
 
23
- ruby bin/sidewatch start
26
+ ruby bin/sidewatch start [--config <path to config file>]
24
27
 
25
28
  To run sidewatch in the foreground, e.g. for testing, run
26
29
 
27
- ruby bin/sidewatch run
30
+ ruby bin/sidewatch run [--config <path to config file>]
31
+
32
+ ## Configuration
33
+
34
+ ### Using ENV variables
35
+
36
+ Sidewatch will use the same environment variables as Sidekiq to determine the Redis server to connect to, i.e. either `REDIS_PROVIDER` or `REDIS_URL`. Please refer to the [Sidekiq wiki](https://github.com/mperham/sidekiq/wiki/Using-Redis#using-an-env-variable) for more information.
37
+
38
+ Sidewatch uses the AWS SDK v2 to connect to CloudWatch. The SDK expects AWS credentials to be provided in one of these locations:
39
+
40
+ * `ENV['AWS_ACCESS_KEY_ID']` and `ENV['AWS_SECRET_ACCESS_KEY']`
41
+ * The shared credentials ini file at `~/.aws/credentials`
42
+ * From an instance profile when running on EC2
43
+
44
+ Please refer to the [SDK's documentation](http://docs.aws.amazon.com/sdkforruby/api/index.html#Configuration) for more information.
45
+
46
+ ### Using the config file
47
+
48
+ When starting Sidewatch, you can pass a config file using the `--config` parameter. The config file should be in YAML format and supports the following keys:
49
+
50
+ ````yaml
51
+ logfile: "/var/log/sidewatch.log"
52
+ sidekiq:
53
+ namespace: "Sidekiq" # namespace used when uploading AWS CloudWatch metrics
54
+ redis:
55
+ url: "redis://localhost:6379/0"
56
+ namespace: "sidekiq" # Redis key namespace used by Sidekiq
57
+ cloudwatch:
58
+ region: "us-west-2"
59
+ ````
28
60
 
29
61
  ## Contributing
30
62
 
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -3,6 +3,8 @@ require "aws-sdk"
3
3
  module Sidewatch
4
4
  class Cloudwatch
5
5
 
6
+ MAX_BATCH_SIZE = 20
7
+
6
8
  attr_accessor :client
7
9
 
8
10
  def initialize(config = {})
@@ -14,13 +16,19 @@ module Sidewatch
14
16
 
15
17
  def send(metrics)
16
18
  metrics.group_by(&:namespace).each do |ns, ns_metrics|
17
- data = metric_data(ns, ns_metrics)
18
- client.put_metric_data(data)
19
+ ns_metrics.each_slice(max_batch_size) do |slice|
20
+ data = metric_data(ns, slice)
21
+ client.put_metric_data(data)
22
+ end
19
23
  end
20
24
  end
21
25
 
22
26
  private
23
27
 
28
+ def max_batch_size
29
+ MAX_BATCH_SIZE
30
+ end
31
+
24
32
  def metric_data(ns, metrics)
25
33
  {
26
34
  namespace: ns,
@@ -36,14 +44,5 @@ module Sidewatch
36
44
  }
37
45
  end
38
46
 
39
- class MockClient
40
- def initialize(config = {})
41
- @out = config.fetch(:output){ $stdout }
42
- end
43
- def put_metric_data(data)
44
- @out << data.to_s
45
- end
46
- end
47
-
48
47
  end
49
48
  end
@@ -1,3 +1,3 @@
1
1
  module Sidewatch
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -47,6 +47,17 @@ module Sidewatch
47
47
  expect(received).to contain_exactly(hash_including(namespace: "Clocks"), hash_including(namespace: "Events"))
48
48
  end
49
49
 
50
+ it "sends metrics in batches of max. 20 entries" do
51
+ metrics = []
52
+ 25.times do |i|
53
+ metrics << Metric.new(namespace: "Clocks", name: "Ticks", value: i, unit: "Count")
54
+ end
55
+
56
+ subject.send(metrics)
57
+
58
+ expect(client).to have_received(:put_metric_data).exactly(2).times
59
+ end
60
+
50
61
  end
51
62
 
52
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidewatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Hecking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,6 +117,8 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - .gitignore
120
+ - .travis.yml
121
+ - CHANGES.md
120
122
  - Gemfile
121
123
  - LICENSE.txt
122
124
  - README.md