gauss 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +31 -2
- data/lib/gauss.rb +11 -2
- data/lib/gauss/version.rb +1 -1
- metadata +13 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a5a934628f0eaab6d8a015ef4482c76e13de451
|
4
|
+
data.tar.gz: a045b03de88b8d5d4c47541d9238b5056bf15be2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e8ef2f96cb3bc2296eae76d790e60d2cdc8a7844c9a954f6501f4b50e16420293faae7845d4179cffb53b53bb5e4559c73b83cead6f5236d62d092568dc0aa7
|
7
|
+
data.tar.gz: 552e23c79f700c22ea8d1df1e8bf642d33c20804fa85f47b737647664ff45a90fbaa136f86546876ebd673b91e39696e69b880267b3a5417be0f06b012a5235c
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Gauss
|
2
2
|
|
3
|
-
|
3
|
+
Sane defaults for [statsd](github.com/etsy/statsd) timers.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,36 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
|
22
|
+
You can configure it to use an app prefix, or it will just use the name of the Rails app (or no prefix if it's not a Rails app).
|
23
|
+
|
24
|
+
```
|
25
|
+
# in application.rb
|
26
|
+
Gauss::prefix = "GreatRailsApp"
|
27
|
+
```
|
28
|
+
|
29
|
+
Then you can either use an env var to set the server (ENV["STATSD_SERVER"]) or you can configure it manually
|
30
|
+
|
31
|
+
```
|
32
|
+
# also in application.rb
|
33
|
+
Gauss::server = "mystats.greatco.com"
|
34
|
+
```
|
35
|
+
|
36
|
+
Then in your application code, you can include the Gauss module in a class, and wrap a block with benchmark
|
37
|
+
```
|
38
|
+
# model.rb
|
39
|
+
class Model < ActiveRecord::Base
|
40
|
+
include Gauss
|
41
|
+
|
42
|
+
def do_something_complex
|
43
|
+
benchmark { 1 + 1 }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
Now in statsd you'll see `Graphite > Stats > Timers > great_rails_app > model > do_something_complex`
|
48
|
+
|
49
|
+
Enjoy
|
50
|
+
|
22
51
|
|
23
52
|
## Contributing
|
24
53
|
|
data/lib/gauss.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "gauss/version"
|
2
2
|
require "statsd"
|
3
|
+
require 'benchmark'
|
3
4
|
|
4
5
|
module Gauss
|
5
6
|
class << self
|
6
|
-
attr_accessor :prefix, :metrics
|
7
|
+
attr_accessor :prefix, :metrics, :mode
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.included(k)
|
@@ -31,7 +32,15 @@ module Gauss
|
|
31
32
|
name += "#{Strings::underscore(Gauss::prefix)}." if Gauss::prefix
|
32
33
|
name += "#{Strings::underscore(self.class.name)}.#{caller[0][/`([^']*)'/, 1]}"
|
33
34
|
name += "-#{Strings::underscore(suffix)}" if suffix
|
34
|
-
|
35
|
+
|
36
|
+
if Gauss::mode.to_sym == :local
|
37
|
+
r = nil
|
38
|
+
m = Benchmark.measure { r = yield }
|
39
|
+
p "#{name}: #{m}"
|
40
|
+
r
|
41
|
+
else
|
42
|
+
Gauss::metrics.time(name) { yield }
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
46
|
|
data/lib/gauss/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gauss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Alejandro Ciniglio
|
@@ -10,12 +9,11 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: bundler
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
@@ -23,7 +21,6 @@ dependencies:
|
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
25
|
- - ~>
|
29
26
|
- !ruby/object:Gem::Version
|
@@ -31,49 +28,43 @@ dependencies:
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: rake
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '0'
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '0'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: pry
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - '>='
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - '>='
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: statsd-ruby
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- -
|
60
|
+
- - '>='
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: '0'
|
71
63
|
type: :runtime
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - '>='
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: '0'
|
79
70
|
description: Easy statsd metrics at the method level
|
@@ -94,32 +85,25 @@ files:
|
|
94
85
|
homepage: http://github.com/adaptly/gauss
|
95
86
|
licenses:
|
96
87
|
- MIT
|
88
|
+
metadata: {}
|
97
89
|
post_install_message:
|
98
90
|
rdoc_options: []
|
99
91
|
require_paths:
|
100
92
|
- lib
|
101
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
94
|
requirements:
|
104
|
-
- -
|
95
|
+
- - '>='
|
105
96
|
- !ruby/object:Gem::Version
|
106
97
|
version: '0'
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
hash: 940151412129564008
|
110
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
99
|
requirements:
|
113
|
-
- -
|
100
|
+
- - '>='
|
114
101
|
- !ruby/object:Gem::Version
|
115
102
|
version: '0'
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
hash: 940151412129564008
|
119
103
|
requirements: []
|
120
104
|
rubyforge_project:
|
121
|
-
rubygems_version:
|
105
|
+
rubygems_version: 2.0.0.rc.2
|
122
106
|
signing_key:
|
123
|
-
specification_version:
|
107
|
+
specification_version: 4
|
124
108
|
summary: Uses smart defaults for statsd timers
|
125
109
|
test_files: []
|