rack-graphite 1.5.0 → 1.6.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODUwYmI4ZDI2ZmFiNjgyYTQ3YWI2NGRhZGEyOWU4NWZkZGE2ZmE5ZQ==
5
- data.tar.gz: !binary |-
6
- MWU3YTJhYWMzZTk2MTQzZDczZGQxNTUwM2E2MzY4NGY1OGIwYmYyYQ==
2
+ SHA1:
3
+ metadata.gz: e89aaa239f7ee56655dfabd3104c922be92290e8
4
+ data.tar.gz: d3346f9a80c452885fd742b392f9313317f6254b
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZGIzMGVhMTNhMWZkYTRmZWQ3ZWFjZjFhNGM1YWYzNzM3ZmY4ODI2MzA3NGY3
10
- ODdjMTRlNjdiNzc0ZmZlZGMyYmM3NDYyZTE5NjE2YmZlZDIwZTE1YjRhNDNk
11
- NjBiMmNjZGUxNzBhYTlkYzFjZDZiZjI4NDNmZWI4YzJjY2RhOWY=
12
- data.tar.gz: !binary |-
13
- MDU2M2Y3NzM5M2MwNTNiYzI5OWEyNTE1YzRlMWJmYmQ1ODc5YzdkMTJiOWRj
14
- NjI4MWNhMTRiZWE5NGFkMTU3ZDRlM2Q5ZmZlNTM5MmQ5MzU1OThmMTM4M2Fl
15
- YmVkYTc3MzQzOWNkYjZhYmU2NDg2YWY3ZDg3MjFiY2VmNmFmYzk=
6
+ metadata.gz: 2ad4f0d8010cd0eaff0a363ae4699ce7fe48cc1d7dd88f4368c47df3a5d3dea718028ae18ef904c6bee47e6ce71027e3645d8d7b3f95f1af6529845ee2ea3395
7
+ data.tar.gz: 53a0673d59b93d5dab4442a1fc3f1f5716f0a3cce8c7b0e59eef89326f7d57f42a821a486f9a2ca16ce44ec11eef19aa8e200666c6322695c0e3049bc2c568ee
data/README.md CHANGED
@@ -52,3 +52,24 @@ By default this will log metrics such as:
52
52
  'Hello!'
53
53
  end
54
54
  end
55
+
56
+ Filter options have been added as an initialization parameter allowing
57
+ specific requests not be processed by [lookout-statsd](https://github.com/lookout/statsd).
58
+ The filter option is assumed to be a list of lambda functions that will be
59
+ applied to rack requests. An example of initializing rack-graphite with a
60
+ filter option is provided below:
61
+
62
+
63
+ require 'rack/graphite'
64
+
65
+ class MyApp < Sinatra::Base
66
+ use Rack::Graphite, { filters: [ lambda{|env| env['PATH_INFO'].include? 'dont_log'} ] }
67
+
68
+ get '/' do
69
+ 'Hello!'
70
+ end
71
+
72
+ get "/dont_log/#{random_number}" do
73
+ 'Causes too many metrics.'
74
+ end
75
+ end
@@ -11,9 +11,16 @@ module Rack
11
11
  def initialize(app, options={})
12
12
  @app = app
13
13
  @prefix = options[:prefix] || PREFIX
14
+ @filters = options[:filters] || []
14
15
  end
15
16
 
16
17
  def call(env)
18
+ @filters.each do |filter|
19
+ if filter.call(env)
20
+ return @app.call(env)
21
+ end
22
+ end
23
+
17
24
  path = env['PATH_INFO'] || '/'
18
25
  method = env['REQUEST_METHOD'] || 'GET'
19
26
  metric = path_to_graphite(method, path)
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Graphite
3
- VERSION = '1.5.0'
3
+ VERSION = '1.6.0'
4
4
  end
5
5
  end
@@ -117,6 +117,17 @@ describe Rack::Graphite do
117
117
  statsd.should_receive(:time)
118
118
  middleware.call({})
119
119
  end
120
+
121
+ context 'with a filtered request' do
122
+ let(:middleware) { described_class.new(app, {filters: [ lambda {|req| req['PATH_INFO'].include? 'onelevel'} ]}) }
123
+ let(:env) { {'PATH_INFO' => '/onelevel'} }
124
+
125
+ it 'does not invoke Lookout::Statsd' do
126
+ statsd.should_not_receive(:time)
127
+ statsd.should_not_receive(:increment)
128
+ expect(middleware.call(env)).to eql([status, headers, response])
129
+ end
130
+ end
120
131
  end
121
132
  end
122
133
 
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - R. Tyler Croy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2017-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lookout-statsd
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  description: Simple Rack middleware for logging request counts/timing information
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - LICENSE
51
51
  - README.md
@@ -65,17 +65,17 @@ require_paths:
65
65
  - lib
66
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ! '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.4.6
78
+ rubygems_version: 2.6.12
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Simple Rack middleware for logging request counts/timing information