rack-graphite 1.0.0 → 1.1.0
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 +7 -0
- data/.gitignore +3 -0
- data/lib/rack/graphite/version.rb +6 -0
- data/lib/rack/graphite.rb +10 -2
- data/rack-graphite.gemspec +1 -1
- data/spec/graphite_spec.rb +32 -0
- metadata +42 -57
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9dd26f2ff86b90d349544fd717a87bcf5f9131f5
|
4
|
+
data.tar.gz: 57d80d9c81e4e44c0fbafb9167a5fbe7dba341e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30ab3c0e5af737e6924f7826969d460f444207c2ae360197659867424d813bb6f4cf3a570f116084f56b6ee4d4b5b9b4b2f37c5731f4c3350abe6840c2cbeddc
|
7
|
+
data.tar.gz: 56895e1ce3137028953dada3d30aacbaa4a4e0f015ffb5d33800bfa28224c8eb236e2e0fd5a619a3bab8a9e75e3943973d794f0e99a3344a42f6f21817eb537b
|
data/.gitignore
CHANGED
data/lib/rack/graphite.rb
CHANGED
@@ -2,8 +2,11 @@ require 'statsd'
|
|
2
2
|
|
3
3
|
module Rack
|
4
4
|
class Graphite
|
5
|
-
VERSION = '1.0.0'
|
6
5
|
PREFIX = 'requests'
|
6
|
+
ID_REGEXP = %r{/\d+(/|$)} # Handle /123/ or /123
|
7
|
+
ID_REPLACEMENT = '/id\1'.freeze
|
8
|
+
GUID_REGEXP = %r{/\h{8}-\h{4}-\h{4}-\h{4}-\h{12}(/|$)} # Handle /GUID/ or /GUID
|
9
|
+
GUID_REPLACEMENT = '/guid\1'.freeze
|
7
10
|
|
8
11
|
def initialize(app, options={})
|
9
12
|
@app = app
|
@@ -27,7 +30,12 @@ module Rack
|
|
27
30
|
if (path.nil?) || (path == '/') || (path.empty?)
|
28
31
|
"#{@prefix}.#{method}.root"
|
29
32
|
else
|
30
|
-
|
33
|
+
# Replace ' ' => '_', '.' => '-'
|
34
|
+
path = path.tr(' .', '_-')
|
35
|
+
path.gsub!(ID_REGEXP, ID_REPLACEMENT)
|
36
|
+
path.gsub!(GUID_REGEXP, GUID_REPLACEMENT)
|
37
|
+
path.tr!('/', '.')
|
38
|
+
|
31
39
|
"#{@prefix}.#{method}#{path}"
|
32
40
|
end
|
33
41
|
end
|
data/rack-graphite.gemspec
CHANGED
data/spec/graphite_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'securerandom'
|
2
3
|
|
3
4
|
describe Rack::Graphite do
|
4
5
|
let(:statsd) { double('Mock Statsd::Client') }
|
@@ -10,6 +11,7 @@ describe Rack::Graphite do
|
|
10
11
|
|
11
12
|
describe '#path_to_graphite' do
|
12
13
|
let(:middleware) { described_class.new(nil) }
|
14
|
+
let(:guid) { SecureRandom.uuid }
|
13
15
|
subject(:graphite) { middleware.path_to_graphite(method, path) }
|
14
16
|
|
15
17
|
context 'GET requests' do
|
@@ -39,6 +41,36 @@ describe Rack::Graphite do
|
|
39
41
|
let(:path) { nil }
|
40
42
|
it { should eql('requests.get.root') }
|
41
43
|
end
|
44
|
+
|
45
|
+
context 'with an id embedded in a path' do
|
46
|
+
let(:path) { '/one/234/five' }
|
47
|
+
it { should eql('requests.get.one.id.five') }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with a path ending in an id' do
|
51
|
+
let(:path) { '/one/234' }
|
52
|
+
it { should eql('requests.get.one.id') }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with a alpha-numeric in a path' do
|
56
|
+
let(:path) { '/one/v1/two' }
|
57
|
+
it { should eql('requests.get.one.v1.two') }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with a guid embedded in a path' do
|
61
|
+
let(:path) { "/one/#{guid}/five" }
|
62
|
+
it { should eql('requests.get.one.guid.five') }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with a path ending in a guid' do
|
66
|
+
let(:path) { "/one/#{guid}" }
|
67
|
+
it { should eql('requests.get.one.guid') }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with something close to a guid in a path' do
|
71
|
+
let(:path) { '/one/deadbeef-babe-cafe/two' }
|
72
|
+
it { should eql('requests.get.one.deadbeef-babe-cafe.two') }
|
73
|
+
end
|
42
74
|
end
|
43
75
|
end
|
44
76
|
|
metadata
CHANGED
@@ -1,95 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-graphite
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- R. Tyler Croy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
|
12
|
+
date: 2014-10-13 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
|
18
|
-
requirements:
|
16
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
19
18
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: "1.3"
|
22
21
|
type: :development
|
23
22
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.3'
|
30
|
-
- !ruby/object:Gem::Dependency
|
23
|
+
version_requirements: *id001
|
24
|
+
- !ruby/object:Gem::Dependency
|
31
25
|
name: lookout-statsd
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version:
|
26
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- &id003
|
29
|
+
- ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
38
32
|
type: :runtime
|
39
33
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
34
|
+
version_requirements: *id002
|
46
35
|
description: Simple Rack middleware for logging request counts/timing information
|
47
|
-
email:
|
36
|
+
email:
|
48
37
|
- rtyler.croy@lookout.com
|
49
38
|
executables: []
|
39
|
+
|
50
40
|
extensions: []
|
41
|
+
|
51
42
|
extra_rdoc_files: []
|
52
|
-
|
43
|
+
|
44
|
+
files:
|
53
45
|
- .gitignore
|
54
46
|
- Gemfile
|
55
47
|
- LICENSE
|
56
48
|
- README.md
|
57
49
|
- Rakefile
|
58
50
|
- lib/rack/graphite.rb
|
51
|
+
- lib/rack/graphite/version.rb
|
59
52
|
- rack-graphite.gemspec
|
60
53
|
- spec/graphite_spec.rb
|
61
54
|
- spec/spec_helper.rb
|
62
55
|
homepage: https://github.com/lookout/rack-graphite
|
63
|
-
licenses:
|
56
|
+
licenses:
|
64
57
|
- MIT
|
58
|
+
metadata: {}
|
59
|
+
|
65
60
|
post_install_message:
|
66
61
|
rdoc_options: []
|
67
|
-
|
62
|
+
|
63
|
+
require_paths:
|
68
64
|
- lib
|
69
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
hash: -1834689501216258839
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
|
-
requirements:
|
81
|
-
- - ! '>='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
hash: -1834689501216258839
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- *id003
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- *id003
|
87
71
|
requirements: []
|
72
|
+
|
88
73
|
rubyforge_project:
|
89
|
-
rubygems_version:
|
74
|
+
rubygems_version: 2.4.1
|
90
75
|
signing_key:
|
91
|
-
specification_version:
|
76
|
+
specification_version: 4
|
92
77
|
summary: Simple Rack middleware for logging request counts/timing information
|
93
|
-
test_files:
|
78
|
+
test_files:
|
94
79
|
- spec/graphite_spec.rb
|
95
80
|
- spec/spec_helper.rb
|