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 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
@@ -1,5 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .ruby-gemset
4
+ .ruby-version
3
5
  .bundle
4
6
  .config
5
7
  coverage
@@ -11,6 +13,7 @@ spec/reports
11
13
  test/tmp
12
14
  test/version_tmp
13
15
  tmp
16
+ Gemfile.lock
14
17
 
15
18
  # YARD artifacts
16
19
  .yardoc
@@ -0,0 +1,6 @@
1
+ module Rack
2
+ class Graphite
3
+ VERSION = '1.1.0'
4
+ end
5
+ end
6
+
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
- path = path.gsub('/', '.')
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
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rack/graphite'
4
+ require 'rack/graphite/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rack-graphite"
@@ -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.0.0
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
- date: 2013-08-08 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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
- none: false
18
- requirements:
16
+ requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirements:
19
18
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.3'
19
+ - !ruby/object:Gem::Version
20
+ version: "1.3"
22
21
  type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
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
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
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: !ruby/object:Gem::Requirement
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
- files:
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
- require_paths:
62
+
63
+ require_paths:
68
64
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
- requirements:
72
- - - ! '>='
73
- - !ruby/object:Gem::Version
74
- version: '0'
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: 1.8.25
74
+ rubygems_version: 2.4.1
90
75
  signing_key:
91
- specification_version: 3
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