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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2de2504dc757ce65e42e18f3fb18afa86a7e89da
4
- data.tar.gz: a707556d8c0cd7423a9713dab0f25b25f0e36c8c
3
+ metadata.gz: 5728ecccdb01d128fdc5e222cf7db8f28078c7d1
4
+ data.tar.gz: 40a2a8ffe2e6a22b859a377916a6ade0777867f3
5
5
  SHA512:
6
- metadata.gz: d4bee1a9d688b961fdc338d95757c38bcbe6b6bed75f84d7101a5fb85c389239bc687eb44bc2c44f2f6f909672cc717e1dc94e2e849cae227d8d2d9e493e5d3d
7
- data.tar.gz: 8de5e6aed0e783986df2e5b5a2cc7c682ea95c8af8b6dff57bedb1a3131ee8fc118f8b8d8e51c3e1ff9e71818bafb86ade1e16a0cd4c4fc012b021f87d7caf2a
6
+ metadata.gz: f3652b37e73e8ea2c2e38297e4ca4967db8e7d4a8c485b17bb74b5b4ad68a700299aea8289ba97b504447a557203a3c28d8afc2524b6c8710884a9f378ad8742
7
+ data.tar.gz: 5b776864017a983996c0ef1d3c27be70bd3f6986b82d3e62a8225128af4b4f36383ad26251b4e3e65f294aee7c1b7afba0eb7c6e537c1d637755a2afc7472ac2
@@ -1,3 +1,7 @@
1
+ # 0.1.16
2
+
3
+ * Beta support for Sinatra monitoring.
4
+
1
5
  # 0.1.15
2
6
 
3
7
  * Add new `application_root` option to override the autodetected location of
@@ -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
 
@@ -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
+
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
  end
4
4
 
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.15
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-22 00:00:00.000000000 Z
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