scout_apm 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +4 -0
- data/lib/scout_apm.rb +1 -0
- data/lib/scout_apm/agent.rb +1 -0
- data/lib/scout_apm/framework_integrations/sinatra.rb +2 -3
- data/lib/scout_apm/instruments/sinatra.rb +61 -0
- data/lib/scout_apm/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5728ecccdb01d128fdc5e222cf7db8f28078c7d1
|
4
|
+
data.tar.gz: 40a2a8ffe2e6a22b859a377916a6ade0777867f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3652b37e73e8ea2c2e38297e4ca4967db8e7d4a8c485b17bb74b5b4ad68a700299aea8289ba97b504447a557203a3c28d8afc2524b6c8710884a9f378ad8742
|
7
|
+
data.tar.gz: 5b776864017a983996c0ef1d3c27be70bd3f6986b82d3e62a8225128af4b4f36383ad26251b4e3e65f294aee7c1b7afba0eb7c6e537c1d637755a2afc7472ac2
|
data/CHANGELOG.markdown
CHANGED
data/lib/scout_apm.rb
CHANGED
@@ -31,6 +31,7 @@ require 'scout_apm/instruments/mongoid'
|
|
31
31
|
require 'scout_apm/instruments/active_record'
|
32
32
|
require 'scout_apm/instruments/action_controller_rails_2'
|
33
33
|
require 'scout_apm/instruments/action_controller_rails_3'
|
34
|
+
require 'scout_apm/instruments/sinatra'
|
34
35
|
require 'scout_apm/instruments/process/process_cpu'
|
35
36
|
require 'scout_apm/instruments/process/process_memory'
|
36
37
|
|
data/lib/scout_apm/agent.rb
CHANGED
@@ -179,6 +179,7 @@ module ScoutApm
|
|
179
179
|
case environment.framework
|
180
180
|
when :rails then install_instrument(ScoutApm::Instruments::ActionControllerRails2)
|
181
181
|
when :rails3_or_4 then install_instrument(ScoutApm::Instruments::ActionControllerRails3)
|
182
|
+
when :sinatra then install_instrument(ScoutApm::Instruments::Sinatra)
|
182
183
|
end
|
183
184
|
|
184
185
|
install_instrument(ScoutApm::Instruments::ActiveRecord)
|
@@ -10,12 +10,11 @@ module ScoutApm
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def version
|
13
|
-
Sinatra::VERSION
|
13
|
+
::Sinatra::VERSION
|
14
14
|
end
|
15
15
|
|
16
16
|
def present?
|
17
|
-
defined?(::Sinatra) &&
|
18
|
-
defined?(::Sinatra::Base)
|
17
|
+
defined?(::Sinatra) && defined?(::Sinatra::Base)
|
19
18
|
end
|
20
19
|
|
21
20
|
# TODO: Fetch the name
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module ScoutApm
|
2
|
+
module Instruments
|
3
|
+
class Sinatra
|
4
|
+
attr_reader :logger
|
5
|
+
|
6
|
+
def initalize(logger=ScoutApm::Agent.instance.logger)
|
7
|
+
@logger = logger
|
8
|
+
@installed = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def installed?
|
12
|
+
@installed
|
13
|
+
end
|
14
|
+
|
15
|
+
def install
|
16
|
+
@installed = true
|
17
|
+
|
18
|
+
if defined?(::Sinatra) && defined?(::Sinatra::Base) && ::Sinatra::Base.private_method_defined?(:dispatch!)
|
19
|
+
ScoutApm::Agent.instance.logger.debug "Instrumenting Sinatra"
|
20
|
+
::Sinatra::Base.class_eval do
|
21
|
+
include ScoutApm::Tracer
|
22
|
+
include ScoutApm::Instruments::SinatraInstruments
|
23
|
+
alias dispatch_without_scout_instruments! dispatch!
|
24
|
+
alias dispatch! dispatch_with_scout_instruments!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module SinatraInstruments
|
31
|
+
def dispatch_with_scout_instruments!
|
32
|
+
scout_controller_action = "Controller/Sinatra/#{scout_sinatra_controller_name(@request)}"
|
33
|
+
self.class.scout_apm_trace(scout_controller_action, :uri => @request.path_info, :ip => @request.ip) do
|
34
|
+
dispatch_without_scout_instruments!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Iterates through the app's routes, returning the matched route that the request should be
|
39
|
+
# grouped under for the metric name.
|
40
|
+
#
|
41
|
+
# If not found, "unknown" is returned. This prevents a metric explosion.
|
42
|
+
#
|
43
|
+
# Nice to have: substitute the param pattern (([^/?#]+)) w/the named key (the +key+ param of the block).
|
44
|
+
def scout_sinatra_controller_name(request)
|
45
|
+
name = 'unknown'
|
46
|
+
verb = request.request_method if request && request.respond_to?(:request_method)
|
47
|
+
Array(self.class.routes[verb]).each do |pattern, keys, conditions, block|
|
48
|
+
if pattern = process_route(pattern, keys, conditions) { pattern.source }
|
49
|
+
name = pattern
|
50
|
+
end
|
51
|
+
end
|
52
|
+
name.gsub!(%r{^[/^]*(.*?)[/\$\?]*$}, '\1')
|
53
|
+
if verb
|
54
|
+
name = [verb,name].join(' ')
|
55
|
+
end
|
56
|
+
name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/lib/scout_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Haynes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-09-
|
12
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/scout_apm/instruments/net_http.rb
|
89
89
|
- lib/scout_apm/instruments/process/process_cpu.rb
|
90
90
|
- lib/scout_apm/instruments/process/process_memory.rb
|
91
|
+
- lib/scout_apm/instruments/sinatra.rb
|
91
92
|
- lib/scout_apm/layaway.rb
|
92
93
|
- lib/scout_apm/layaway_file.rb
|
93
94
|
- lib/scout_apm/metric_meta.rb
|