scout_rails 1.0.6 → 1.0.7
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.
- data/CHANGELOG.markdown +5 -0
- data/lib/scout_rails/instruments/sinatra_instruments.rb +26 -18
- data/lib/scout_rails/version.rb +1 -1
- data/lib/scout_rails.rb +3 -0
- metadata +2 -2
data/CHANGELOG.markdown
CHANGED
@@ -1,33 +1,41 @@
|
|
1
1
|
module ScoutRails::Instruments
|
2
2
|
module SinatraInstruments
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
def dispatch_with_scout_instruments!
|
4
|
+
scout_controller_action = "Controller/Sinatra/#{scout_sinatra_controller_name(@request)}"
|
5
|
+
self.class.trace(scout_controller_action, :uri => @request.path_info) do
|
6
|
+
dispatch_without_scout_instruments!
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Iterates through the app's routes, returning the matched route that the request should be
|
11
|
+
# grouped under for the metric name.
|
12
|
+
#
|
13
|
+
# If not found, "unknown" is returned. This prevents a metric explosion.
|
14
|
+
#
|
15
|
+
# Nice to have: substitute the param pattern (([^/?#]+)) w/the named key (the +key+ param of the block).
|
16
|
+
def scout_sinatra_controller_name(request)
|
17
|
+
name = 'unknown'
|
18
|
+
verb = request.request_method if request && request.respond_to?(:request_method)
|
19
|
+
Array(self.class.routes[verb]).each do |pattern, keys, conditions, block|
|
20
|
+
if pattern = process_route(pattern, keys, conditions) { pattern.source }
|
21
|
+
name = pattern
|
12
22
|
end
|
13
23
|
end
|
14
24
|
name.gsub!(%r{^[/^]*(.*?)[/\$\?]*$}, '\1')
|
15
|
-
|
16
|
-
|
17
|
-
scout_controller_action = "Controller/Sinatra/#{name}"
|
18
|
-
self.class.trace(scout_controller_action, :uri => @request.path_info) do
|
19
|
-
route_eval_without_scout_instruments(&blockarg)
|
25
|
+
if verb
|
26
|
+
name = [verb,name].join(' ')
|
20
27
|
end
|
21
|
-
|
28
|
+
name
|
29
|
+
end
|
22
30
|
end # SinatraInstruments
|
23
31
|
end # ScoutRails::Instruments
|
24
32
|
|
25
|
-
if defined?(::Sinatra) && defined?(::Sinatra::Base)
|
33
|
+
if defined?(::Sinatra) && defined?(::Sinatra::Base) && Sinatra::Base.private_method_defined?(:dispatch!)
|
26
34
|
ScoutRails::Agent.instance.logger.debug "Instrumenting Sinatra"
|
27
35
|
::Sinatra::Base.class_eval do
|
28
36
|
include ScoutRails::Tracer
|
29
37
|
include ::ScoutRails::Instruments::SinatraInstruments
|
30
|
-
alias
|
31
|
-
alias
|
38
|
+
alias dispatch_without_scout_instruments! dispatch!
|
39
|
+
alias dispatch! dispatch_with_scout_instruments!
|
32
40
|
end
|
33
41
|
end
|
data/lib/scout_rails/version.rb
CHANGED
data/lib/scout_rails.rb
CHANGED
@@ -3,6 +3,9 @@ end
|
|
3
3
|
require 'socket'
|
4
4
|
require 'set'
|
5
5
|
require 'net/http'
|
6
|
+
require 'logger'
|
7
|
+
require 'yaml'
|
8
|
+
require 'cgi'
|
6
9
|
require File.expand_path('../scout_rails/version.rb', __FILE__)
|
7
10
|
require File.expand_path('../scout_rails/agent.rb', __FILE__)
|
8
11
|
require File.expand_path('../scout_rails/agent/logging.rb', __FILE__)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Monitors a Ruby on Rails application and reports detailed metrics on
|
16
16
|
performance to Scout, a hosted monitoring service.
|