archimedes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +6 -0
- data/archimedes.gemspec +29 -0
- data/lib/archimedes.rb +37 -0
- data/lib/archimedes/config.rb +11 -0
- data/lib/archimedes/version.rb +3 -0
- data/spec/lib/archimedes_spec.rb +69 -0
- data/spec/spec_helper.rb +10 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 635ebecb31041c1d2e772734c180b992d8246c4f
|
4
|
+
data.tar.gz: 60f946edf04f8ea098ac7a69ed4709c89a7c258f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35b188a0924151efcdd3ab486cf18cec2b4f55ab7abd25a957cec854014b0e6bdbe9213b9f947f8f66dc27bf776159aadd5b2208ed9bf99506a5f6175b5aa169
|
7
|
+
data.tar.gz: 8caae4e2fabbacf188b79c0efa5cb49f9f7d12fc00cccd9ede75a26b86d6deb5c6eac58fca359bf94c42f809ce09849a0c255dc1d2d21ce18c069a5fdf0c463b
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
archimedes
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 ShopKeep POS
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Archimedes
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/shopkeep/archimedes.png?branch=master)](https://travis-ci.org/shopkeep/archimedes)
|
4
|
+
|
5
|
+
A lightweight wrapper for StatsD and it's configuration.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'archimedes'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install archimedes
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Archimedes uses [Isomer](https://github.com/pguelpa/isomer) for managing it's configuration.
|
24
|
+
|
25
|
+
##### Example archimedes.yml
|
26
|
+
|
27
|
+
development:
|
28
|
+
port: 1234
|
29
|
+
namespace: 'foo.bar'
|
30
|
+
host: 'example.org'
|
31
|
+
|
32
|
+
##### Configure Archimedes
|
33
|
+
|
34
|
+
file = Rails.root.join('config', 'archimedes.yml')
|
35
|
+
base = Rails.env
|
36
|
+
config = Archimedes::Config.from(:yaml, file: file, base: base)
|
37
|
+
|
38
|
+
ARCHIMEDES = Archimedes.new(config)
|
39
|
+
|
40
|
+
##### Send some metrics
|
41
|
+
|
42
|
+
ARCHIMEDES.increment('foo')
|
43
|
+
|
44
|
+
ARCHIMEDES.decrement('foo')
|
45
|
+
|
46
|
+
ARCHIMEDES.count('foo', 30)
|
47
|
+
|
48
|
+
ARCHIMEDES.gauge('production.deployments', 1)
|
49
|
+
|
50
|
+
ARCHIMEDES.time('foo') do
|
51
|
+
zomg_long_task
|
52
|
+
end
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/archimedes.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'archimedes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'archimedes'
|
8
|
+
spec.version = Archimedes::VERSION
|
9
|
+
spec.authors = ['Duncan Grazier', 'Paul Guelpa', 'Sander Hartlage']
|
10
|
+
spec.email = ['itsmeduncan@gmail.com', 'paul.guelpa@gmail.com', 'sander.hartlage@gmail.com']
|
11
|
+
spec.description = %q{A lightweight wrapper for statsd-ruby}
|
12
|
+
spec.summary = %q{Wrap up the configration, and usage of StatsD}
|
13
|
+
spec.homepage = 'https://www.github.com/shopkeep/archimedes'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'mocha', '~> 0.14.0'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 2.14.1'
|
25
|
+
spec.add_development_dependency 'simplecov', '~> 0.7.1'
|
26
|
+
|
27
|
+
spec.add_dependency 'isomer', '~> 0.1.3'
|
28
|
+
spec.add_dependency 'statsd-ruby', '~> 1.2.1'
|
29
|
+
end
|
data/lib/archimedes.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'archimedes/config'
|
2
|
+
require 'archimedes/version'
|
3
|
+
require 'statsd'
|
4
|
+
|
5
|
+
class Archimedes
|
6
|
+
|
7
|
+
attr_reader :service
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
@config = config
|
11
|
+
@service = Statsd.new(@config.host, @config.port)
|
12
|
+
@service.namespace = @config.namespace
|
13
|
+
end
|
14
|
+
|
15
|
+
def increment(metric, rate = 1)
|
16
|
+
count(metric, 1, rate)
|
17
|
+
end
|
18
|
+
|
19
|
+
def decrement(metric, rate = 1)
|
20
|
+
count(metric, -1, rate)
|
21
|
+
end
|
22
|
+
|
23
|
+
def count(metric, delta, rate = 1)
|
24
|
+
service.count(metric, delta, rate)
|
25
|
+
end
|
26
|
+
|
27
|
+
def gauge(metric, value, rate = 1)
|
28
|
+
service.gauge(metric, value, rate)
|
29
|
+
end
|
30
|
+
|
31
|
+
def time(metric, rate = 1)
|
32
|
+
service.time(metric, rate) do
|
33
|
+
yield
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Archimedes do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@config = stub(host: 'example.org', port: 9999, namespace: 'test.archimedes')
|
7
|
+
@archimedes = described_class.new(@config)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.increment' do
|
11
|
+
it 'calls the service\'s count method with 1' do
|
12
|
+
@archimedes.service.expects(:count).with('foo.metric', 1, 1)
|
13
|
+
@archimedes.increment('foo.metric')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'passes the rate along if present' do
|
17
|
+
@archimedes.service.expects(:count).with(anything, 1, 0.25)
|
18
|
+
@archimedes.increment(anything, 0.25)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.decrement' do
|
23
|
+
it 'calls the service\'s count method with -1' do
|
24
|
+
@archimedes.service.expects(:count).with('bar.metric', -1, 1)
|
25
|
+
@archimedes.decrement('bar.metric')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'passes the rate along if present' do
|
29
|
+
@archimedes.service.expects(:count).with(anything, -1, 0.9)
|
30
|
+
@archimedes.decrement(anything, 0.9)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.count' do
|
35
|
+
it 'calls the service\'s count method with the count size' do
|
36
|
+
@archimedes.service.expects(:count).with('baz.metric', 12, 1)
|
37
|
+
@archimedes.count('baz.metric', 12)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'passes the rate along if present' do
|
41
|
+
@archimedes.service.expects(:count).with(anything, -15, 0.75)
|
42
|
+
@archimedes.count(anything, -15, 0.75)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.gauge' do
|
47
|
+
it 'calls the service\'s gauge method' do
|
48
|
+
@archimedes.service.expects(:gauge).with('sk.gauge', 11, 1)
|
49
|
+
@archimedes.gauge('sk.gauge', 11)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'passes the rate along if present' do
|
53
|
+
@archimedes.service.expects(:gauge).with(anything, 6, 0.1)
|
54
|
+
@archimedes.gauge(anything, 6, 0.1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.time' do
|
59
|
+
it 'calls the service\'s time method' do
|
60
|
+
@archimedes.service.expects(:time).with('sk.time', 1)
|
61
|
+
@archimedes.time('sk.time') {}
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'passes the rate along if present' do
|
65
|
+
@archimedes.service.expects(:time).with('sk.time', 0.1)
|
66
|
+
@archimedes.time('sk.time', 0.1) {}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: archimedes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Duncan Grazier
|
8
|
+
- Paul Guelpa
|
9
|
+
- Sander Hartlage
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.3'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: mocha
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.14.0
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.14.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rake
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.14.1
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.14.1
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: simplecov
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.7.1
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.7.1
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: isomer
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.1.3
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.1.3
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: statsd-ruby
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 1.2.1
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.2.1
|
113
|
+
description: A lightweight wrapper for statsd-ruby
|
114
|
+
email:
|
115
|
+
- itsmeduncan@gmail.com
|
116
|
+
- paul.guelpa@gmail.com
|
117
|
+
- sander.hartlage@gmail.com
|
118
|
+
executables: []
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- .gitignore
|
123
|
+
- .rspec
|
124
|
+
- .ruby-gemset
|
125
|
+
- .ruby-version
|
126
|
+
- .travis.yml
|
127
|
+
- Gemfile
|
128
|
+
- LICENSE.txt
|
129
|
+
- README.md
|
130
|
+
- Rakefile
|
131
|
+
- archimedes.gemspec
|
132
|
+
- lib/archimedes.rb
|
133
|
+
- lib/archimedes/config.rb
|
134
|
+
- lib/archimedes/version.rb
|
135
|
+
- spec/lib/archimedes_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
homepage: https://www.github.com/shopkeep/archimedes
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.0.3
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Wrap up the configration, and usage of StatsD
|
161
|
+
test_files:
|
162
|
+
- spec/lib/archimedes_spec.rb
|
163
|
+
- spec/spec_helper.rb
|