instrumental_agent 0.6.1 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ ### 0.7 [January 2, 2012]
2
+ * .notice added to API to allow tracking project-wide events on graphs
3
+ * Removed Rack middleware
4
+ * Logs to STDERR instead of /dev/null
5
+ * Synchronous mode can be specified in agent initialization contributed by [janxious] from (https://github.com/expectedbehavior/)
6
+ * Added CHANGELOG :)
7
+
8
+ ### 0.6.1 [December 16, 2011]
9
+ * Documentation cleanup
10
+
11
+ ### 0.6 [December 13, 2011]
12
+ * Synchronous agent support to allow blocking send of metrics
13
+ * Message buffer increased to 5000
14
+ * Code cleanup
15
+
16
+ ### 0.5.1 [December 12, 2011]
17
+ * instrument_server moved to instrumental_tools gem (https://github.com/fastestforward/instrumental_tools)
18
+
19
+ ### 0.5 [December 9, 2011]
20
+ * Allow negative numbers to be submitted
21
+ * agent logger now can be configured per instance
22
+ * Better RSpec formatting for tests
23
+
24
+ ### 0.4 [December 1, 2011]
25
+ * Support reconnecting on fork() for forking servers like Passenger
26
+
27
+ ### 0.3 [November 17, 2011]
28
+ * Support for test_mode on agent to cause submitted metrics to be thrown away when it reaches Instrumental servers
29
+ * Fix version not being sent in agent hello
30
+ * Exceptions in agent get swallowed and reported to logger
31
+
32
+ ### 0.2 [November 15, 2011]
33
+ * Refactored agent to use TCPSocket instead of EventMachine
34
+
35
+ ### 0.1.6 [November 14, 2011]
36
+ * Middleware doesn't automatically inject itself into Rack middleware stack
37
+
38
+ ### 0.1.5 [November 1, 2011]
39
+ * Documentation changes
40
+
41
+ ### 0.1.4 [November 1, 2011]
42
+ * Documentation changes
43
+
44
+ ### 0.1.3 [October 31, 2011]
45
+ * Rename the watch_server command to instrument_server
46
+ * Documentation changes
47
+
48
+ ### 0.1.2 [October 30, 2011]
49
+ * Add enabled flag to control agent use in test/non-development environments
50
+ * watch_server runs every 10s
51
+
52
+ ### 0.1.1 [October 27, 2011]
53
+ * Linux support for watch_server
54
+ * Documentation changes
55
+
56
+ ### 0.1 [OCtober 27, 2011]
57
+ * Initial version
data/README.md CHANGED
@@ -34,6 +34,14 @@ from any problems our service might suffer. If it is unable to connect
34
34
  to the service, it will discard data after reaching a low memory
35
35
  threshold.
36
36
 
37
+ Want to track an event (like an application deploy, or downtime)? You can capture events that
38
+ are instantaneous, or events that happen over a period of time.
39
+
40
+ ```sh
41
+ I.notice('Jeffy deployed rev ef3d6a') # instantaneous event
42
+ I.notice('Testing socket buffer increase', 3.days.ago, 20.minutes) # an event with a duration
43
+ ```
44
+
37
45
  ## Backfilling
38
46
 
39
47
  Streaming data is better with a little historical context. Instrumental
@@ -56,7 +64,7 @@ User.find_each do |user|
56
64
  end
57
65
  ```
58
66
 
59
- ## Server stats
67
+ ## Server Stats
60
68
 
61
69
  Want some general server stats (load, memory, etc.)? Check out the
62
70
  [instrumental_tools](https://github.com/fastestforward/instrumental_tools)
@@ -67,18 +75,27 @@ gem install instrumental_tools
67
75
  instrument_server
68
76
  ```
69
77
 
70
- ## Rack middleware
71
-
72
- Running under Rails? You can also give our experimental Rack middleware
73
- a shot by initializing it with:
74
-
75
- ```sh
76
- Instrumental::Middleware.boot
77
- ```
78
+ ## Agent Control
78
79
 
79
80
  Need to quickly disable the agent? set :enabled to false on
80
81
  initialization and you don't need to change any application code.
81
82
 
83
+
84
+ ## Capistrano Integration
85
+
86
+ Add `require "instrumental/capistrano"` to your capistrano configuration
87
+ and your deploys will be tracked automatically by Instrumental.
88
+
89
+ The following configuration will be added:
90
+
91
+ ```ruby
92
+ before "deploy", "instrumental:util:deploy_start"
93
+ after "deploy", "instrumental:util:deploy_end"
94
+ before "deploy:migrations", "instrumental:util:deploy_start"
95
+ after "deploy:migrations", "instrumental:util:deploy_end"
96
+ after "instrumental:util:deploy_end", "instrumental:record_deploy_notice"
97
+ ```
98
+
82
99
  ## Troubleshooting & Help
83
100
 
84
101
  We are here to help, please email us at
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.email = ["support@instrumentalapp.com"]
9
9
  s.homepage = "http://github.com/fastestforward/instrumental_agent"
10
10
  s.summary = %q{Agent for reporting data to instrumentalapp.com}
11
- s.description = %q{Keep track of anything.}
11
+ s.description = %q{Track anything.}
12
12
 
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -20,8 +20,12 @@ module Instrumental
20
20
  @logger = l
21
21
  end
22
22
 
23
- def self.logger(force = false)
24
- @logger ||= Logger.new(File.open('/dev/null', 'a')) # append mode so it's forksafe
23
+ def self.logger
24
+ if !@logger
25
+ @logger = Logger.new(STDERR)
26
+ @logger.level = Logger::WARN
27
+ end
28
+ @logger
25
29
  end
26
30
 
27
31
  def self.all
@@ -40,18 +44,20 @@ module Instrumental
40
44
  # Instrumental::Agent.new(API_KEY, :collector => 'hostname:port')
41
45
  def initialize(api_key, options = {})
42
46
  default_options = {
43
- :collector => 'instrumentalapp.com:8000',
44
- :enabled => true,
45
- :test_mode => false,
47
+ :collector => 'instrumentalapp.com:8000',
48
+ :enabled => true,
49
+ :test_mode => false,
50
+ :synchronous => false
46
51
  }
47
52
  options = default_options.merge(options)
48
53
  collector = options[:collector].split(':')
49
54
 
50
- @api_key = api_key
51
- @host = collector[0]
52
- @port = (collector[1] || 8000).to_i
53
- @enabled = options[:enabled]
54
- @test_mode = options[:test_mode]
55
+ @api_key = api_key
56
+ @host = collector[0]
57
+ @port = (collector[1] || 8000).to_i
58
+ @enabled = options[:enabled]
59
+ @test_mode = options[:test_mode]
60
+ @synchronous = options[:synchronous]
55
61
  @pid = Process.pid
56
62
 
57
63
 
@@ -93,6 +99,21 @@ module Instrumental
93
99
  nil
94
100
  end
95
101
 
102
+ # Send a notice to the server (deploys, downtime, etc.)
103
+ #
104
+ # agent.notice('A notice')
105
+ def notice(note, time = Time.now, duration = 0)
106
+ if valid_note?(note)
107
+ send_command("notice", time.to_i, duration.to_i, note)
108
+ note
109
+ else
110
+ nil
111
+ end
112
+ rescue Exception => e
113
+ report_exception(e)
114
+ nil
115
+ end
116
+
96
117
  def enabled?
97
118
  @enabled
98
119
  end
@@ -111,6 +132,10 @@ module Instrumental
111
132
 
112
133
  private
113
134
 
135
+ def valid_note?(note)
136
+ note !~ /[\n\r]/
137
+ end
138
+
114
139
  def valid?(metric, value, time)
115
140
  valid_metric = metric =~ /^([\d\w\-_]+\.)*[\d\w\-_]+$/i
116
141
  valid_value = value.to_s =~ /^-?\d+(\.\d+)?$/
@@ -209,7 +234,7 @@ module Instrumental
209
234
  logger.error err.to_s
210
235
  if command_and_args
211
236
  logger.debug "requeueing: #{command_and_args}"
212
- @queue << command_and_args
237
+ @queue << command_and_args
213
238
  end
214
239
  disconnect
215
240
  @failures += 1
@@ -0,0 +1,42 @@
1
+ require 'capistrano'
2
+ require 'instrumental_agent'
3
+
4
+ if Capistrano::Configuration.instance
5
+ Capistrano::Configuration.instance.load do
6
+ namespace :instrumental do
7
+ namespace :util do
8
+ desc "marker for beginning of deploy"
9
+ task :deploy_start do
10
+ @instrumental_deploy_start = Time.now
11
+ end
12
+
13
+ desc "marker for end of deploy"
14
+ task :deploy_end do
15
+ @instrumental_deploy_end = Time.now
16
+ end
17
+ end
18
+
19
+ desc "send a notice to instrumental about the deploy"
20
+ task :record_deploy_notice do
21
+ @instrumental_deploy_start ||= Time.now
22
+ @instrumental_deploy_end ||= Time.now
23
+ deploy_duration_in_seconds = (@instrumental_deploy_end - @instrumental_deploy_start).to_i
24
+ deployer = Etc.getlogin.chomp
25
+ agent_options = {}
26
+ agent_options[:collector] = instrumental_host if exists?(:instrumental_host)
27
+ agent = Instrumental::Agent.new(instrumental_key, agent_options)
28
+ agent.synchronous = true
29
+ agent.notice("#{deployer} deployed #{current_revision}",
30
+ @instrumental_deploy_start,
31
+ deploy_duration_in_seconds)
32
+ logger.info("Notified Instrumental of deployment")
33
+ end
34
+ end
35
+
36
+ before "deploy", "instrumental:util:deploy_start"
37
+ after "deploy", "instrumental:util:deploy_end"
38
+ before "deploy:migrations", "instrumental:util:deploy_start"
39
+ after "deploy:migrations", "instrumental:util:deploy_end"
40
+ after "instrumental:util:deploy_end", "instrumental:record_deploy_notice"
41
+ end
42
+ end
@@ -1,85 +1,7 @@
1
1
  module Instrumental
2
2
  class Middleware
3
3
  def self.boot
4
- if @stack = detect_stack
5
- @stack.install_middleware
6
- @enabled = true
7
- else
8
- @enabled = false
9
- end
10
- end
11
-
12
- def self.stack; @stack; end
13
-
14
- def self.enabled; @enabled; end
15
- def self.enabled=(v); @enabled = v; end
16
-
17
- def initialize(app)
18
- @app = app
19
- end
20
-
21
- def stack
22
- Middleware.stack
23
- end
24
-
25
- def measure(env, &block)
26
- response = nil
27
- if Middleware.enabled
28
- request = Rack::Request.new(env)
29
- key_parts = stack.recognize_uri(request)
30
- if key = key_parts.join(".")
31
- exc = nil
32
- tms = Benchmark.measure do
33
- begin
34
- response = yield
35
- rescue Exception => e
36
- exc = e
37
- end
38
- end
39
- begin
40
- Agent.all.each do |agent|
41
- if exc
42
- agent.increment("%s.error.%s" % [key, exc.class])
43
- end
44
- if response && response.first
45
- agent.increment("%s.status.%i" % [key, response.first])
46
- else
47
- agent.increment(key)
48
- end
49
- end
50
- rescue Exception => e
51
- stack.log "Error occurred sending stats: #{e}"
52
- stack.log e.backtrace.join("\n")
53
- end
54
- raise exc if exc
55
- end
56
- end
57
- response ||= yield
58
- end
59
-
60
- def call(env)
61
- measure(env) do
62
- @app.call(env)
63
- end
64
- end
65
-
66
- class Stack
67
- def self.default_logger
68
- @logger ||= Logger.new('/dev/null')
69
- end
70
-
71
- def log(msg)
72
- Stack.default_logger.error(msg)
73
- end
74
- end
75
-
76
- private
77
-
78
- def self.detect_stack
79
- [Rails3, Rails23].collect { |klass| klass.create }.detect { |obj| !obj.nil? }
4
+ Instrumental::Agent.logger.warn "The Instrumental Rails middlware has been removed - contact support@instrumentalapp.com for more information"
80
5
  end
81
6
  end
82
7
  end
83
-
84
- require 'instrumental/rack/rails3'
85
- require 'instrumental/rack/rails23'
@@ -1,3 +1,3 @@
1
1
  module Instrumental
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7"
3
3
  end
@@ -6,6 +6,7 @@ end
6
6
 
7
7
  describe Instrumental::Agent, "disabled" do
8
8
  before do
9
+ Instrumental::Agent.logger.level = Logger::UNKNOWN
9
10
  @server = TestServer.new
10
11
  @agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :enabled => false)
11
12
  end
@@ -66,12 +67,19 @@ describe Instrumental::Agent, "enabled in test_mode" do
66
67
  wait
67
68
  @server.commands.last.should == "increment increment_test 1 #{now.to_i}"
68
69
  end
70
+
71
+ it "should send notices to the server" do
72
+ tm = Time.now
73
+ @agent.notice("Test note", tm)
74
+ wait
75
+ @server.commands.join("\n").should include("notice #{tm.to_i} 0 Test note")
76
+ end
69
77
  end
70
78
 
71
79
  describe Instrumental::Agent, "enabled" do
72
80
  before do
73
81
  @server = TestServer.new
74
- @agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port)
82
+ @agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :synchronous => false)
75
83
  end
76
84
 
77
85
  after do
@@ -244,4 +252,38 @@ describe Instrumental::Agent, "enabled" do
244
252
  wait
245
253
  @server.commands.join("\n").should_not include("increment agent.invalid_value")
246
254
  end
255
+
256
+ it "should send notices to the server" do
257
+ tm = Time.now
258
+ @agent.notice("Test note", tm)
259
+ wait
260
+ @server.commands.join("\n").should include("notice #{tm.to_i} 0 Test note")
261
+ end
262
+
263
+ it "should prevent a note w/ newline characters from being sent to the server" do
264
+ @agent.notice("Test note\n").should be_nil
265
+ wait
266
+ @server.commands.join("\n").should_not include("notice Test note")
267
+ end
268
+ end
269
+
270
+ describe Instrumental::Agent, "enabled with sync option" do
271
+ before do
272
+ @server = TestServer.new
273
+ @agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :synchronous => true)
274
+ end
275
+
276
+ it "should send all data in synchronous mode" do
277
+ with_constants('Instrumental::Agent::MAX_BUFFER' => 3) do
278
+ 5.times do |i|
279
+ @agent.increment('overflow_test', i + 1, 300)
280
+ end
281
+ wait # let the server receive the commands
282
+ @server.commands.should include("increment overflow_test 1 300")
283
+ @server.commands.should include("increment overflow_test 2 300")
284
+ @server.commands.should include("increment overflow_test 3 300")
285
+ @server.commands.should include("increment overflow_test 4 300")
286
+ @server.commands.should include("increment overflow_test 5 300")
287
+ end
288
+ end
247
289
  end
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: instrumental_agent
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.7'
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Elijah Miller
14
9
  - Christopher Zelenak
15
10
  - Kristopher Chambers
@@ -17,130 +12,103 @@ authors:
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2011-12-16 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :development
34
- prerelease: false
15
+ date: 2012-01-02 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
35
18
  name: rake
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
19
+ requirement: &70270468082260 !ruby/object:Gem::Requirement
39
20
  none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 2
46
- - 0
47
- version: "2.0"
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
48
25
  type: :development
49
26
  prerelease: false
27
+ version_requirements: *70270468082260
28
+ - !ruby/object:Gem::Dependency
50
29
  name: rspec
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- requirement: &id003 !ruby/object:Gem::Requirement
30
+ requirement: &70270468080880 !ruby/object:Gem::Requirement
54
31
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '2.0'
62
36
  type: :development
63
37
  prerelease: false
38
+ version_requirements: *70270468080880
39
+ - !ruby/object:Gem::Dependency
64
40
  name: guard
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
41
+ requirement: &70270468105920 !ruby/object:Gem::Requirement
68
42
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
76
47
  type: :development
77
48
  prerelease: false
49
+ version_requirements: *70270468105920
50
+ - !ruby/object:Gem::Dependency
78
51
  name: guard-rspec
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- requirement: &id005 !ruby/object:Gem::Requirement
52
+ requirement: &70270468104540 !ruby/object:Gem::Requirement
82
53
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
90
58
  type: :development
91
59
  prerelease: false
60
+ version_requirements: *70270468104540
61
+ - !ruby/object:Gem::Dependency
92
62
  name: growl_notify
93
- version_requirements: *id005
94
- - !ruby/object:Gem::Dependency
95
- requirement: &id006 !ruby/object:Gem::Requirement
63
+ requirement: &70270468102900 !ruby/object:Gem::Requirement
96
64
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
104
69
  type: :development
105
70
  prerelease: false
71
+ version_requirements: *70270468102900
72
+ - !ruby/object:Gem::Dependency
106
73
  name: rb-fsevent
107
- version_requirements: *id006
108
- - !ruby/object:Gem::Dependency
109
- requirement: &id007 !ruby/object:Gem::Requirement
74
+ requirement: &70270468099960 !ruby/object:Gem::Requirement
110
75
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
118
80
  type: :development
119
81
  prerelease: false
82
+ version_requirements: *70270468099960
83
+ - !ruby/object:Gem::Dependency
120
84
  name: fuubar
121
- version_requirements: *id007
122
- description: Keep track of anything.
123
- email:
85
+ requirement: &70270468099200 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: *70270468099200
94
+ description: Track anything.
95
+ email:
124
96
  - support@instrumentalapp.com
125
97
  executables: []
126
-
127
98
  extensions: []
128
-
129
99
  extra_rdoc_files: []
130
-
131
- files:
100
+ files:
132
101
  - .gitignore
133
102
  - .rspec
103
+ - CHANGELOG.md
134
104
  - Gemfile
135
105
  - Guardfile
136
106
  - README.md
137
107
  - Rakefile
138
108
  - instrumental_agent.gemspec
139
109
  - lib/instrumental/agent.rb
110
+ - lib/instrumental/capistrano.rb
140
111
  - lib/instrumental/rack/middleware.rb
141
- - lib/instrumental/rack/rails23.rb
142
- - lib/instrumental/rack/rails3.rb
143
- - lib/instrumental/rack/rails3/middleware_bootstrap.rb
144
112
  - lib/instrumental/version.rb
145
113
  - lib/instrumental_agent.rb
146
114
  - spec/agent_spec.rb
@@ -148,38 +116,30 @@ files:
148
116
  - spec/test_server.rb
149
117
  homepage: http://github.com/fastestforward/instrumental_agent
150
118
  licenses: []
151
-
152
119
  post_install_message:
153
120
  rdoc_options: []
154
-
155
- require_paths:
121
+ require_paths:
156
122
  - lib
157
- required_ruby_version: !ruby/object:Gem::Requirement
123
+ required_ruby_version: !ruby/object:Gem::Requirement
158
124
  none: false
159
- requirements:
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- hash: 3
163
- segments:
164
- - 0
165
- version: "0"
166
- required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
130
  none: false
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- hash: 3
172
- segments:
173
- - 0
174
- version: "0"
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
175
135
  requirements: []
176
-
177
136
  rubyforge_project:
178
137
  rubygems_version: 1.8.10
179
138
  signing_key:
180
139
  specification_version: 3
181
140
  summary: Agent for reporting data to instrumentalapp.com
182
- test_files:
141
+ test_files:
183
142
  - spec/agent_spec.rb
184
143
  - spec/spec_helper.rb
185
144
  - spec/test_server.rb
145
+ has_rdoc:
@@ -1,27 +0,0 @@
1
- module Instrumental
2
- class Middleware
3
- class Rails23 < Stack
4
- def self.create
5
- if (defined?(::RAILS_VERSION) && const_get(:RAILS_VERSION).to_s =~ /^2\.3/) ||
6
- (defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^2\.3/)
7
- new
8
- end
9
- end
10
-
11
- def install_middleware
12
- Rails.configuration.middleware.use Instrumental::Middleware
13
- end
14
-
15
- def log(msg)
16
- Rails.logger.error msg
17
- end
18
-
19
- def recognize_uri(request)
20
- params = ActionController::Routing::Routes.recognize_path(request.path, request.env.merge(:method => request.env["REQUEST_METHOD"].downcase.to_sym))
21
- ["controller", params[:controller], params[:action]]
22
- rescue ActionController::RoutingError => e
23
- ["controller", "unknown"]
24
- end
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- module Instrumental
2
- class Middleware
3
- class Rails3 < Stack
4
- def self.create
5
- if defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^3/
6
- new
7
- end
8
- end
9
-
10
- def install_middleware
11
- require 'instrumental/rack/rails3/middleware_bootstrap'
12
- end
13
-
14
- def log(msg)
15
- Rails.logger.error msg
16
- end
17
-
18
- def recognize_uri(request)
19
- Rails.application.routes.finalize!
20
- params = Rails.application.routes.recognize_path(request.url, request.env)
21
- ["controller", params[:controller], params[:action]]
22
- rescue ActionController::RoutingError => e
23
- ["controller", "unknown"]
24
- end
25
- end
26
- end
27
- end
@@ -1,6 +0,0 @@
1
- module Instrumental
2
- class MiddlewareBootstrap < Rails::Railtie
3
- config.app_middleware.use Instrumental::Middleware
4
-
5
- end
6
- end