scout_apm 2.1.24 → 2.1.26

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: 4c94cdf557213ec5d7954875a37beee23ec18353
4
- data.tar.gz: d40e259ae8115101adf203e8dff98c6f193cc55d
3
+ metadata.gz: f204bb73b571d29f24c1ef41ef3e643dd53ede06
4
+ data.tar.gz: 420211b4994ee6437de618b5fd6cea516881d6aa
5
5
  SHA512:
6
- metadata.gz: c80c11514d116b0d926c2b7e0992c44e4e4cc0be120677d9ac0651fce7069247184e6147cfb081802694792a13fa98db51278f26889ec52b4a4e3d4ac4dc7c0b
7
- data.tar.gz: '05465810d1d6f23b287b01daae791d456742adc657fd707d4282d10d822e14420010d8ac7c264034f3271b8c84a48717f842c242685257f8bf703b60addb886c'
6
+ metadata.gz: e8095e97d2fc53bcad1a8b100ea13f574795cfbe1bc45a7d4717c7c356f2eab3f9d28ff09cd65df0485fca4a82439fb9d13aa668654a2e8599debc6b97ace906
7
+ data.tar.gz: ebe375745cb23716f9930cf12221d9ee11775ee0ba37a0fe89c510d342b2618171b80724201e9f76d141d612b919d6ac41486c2fc07dd9c6ad727ac4e454a17f
@@ -83,6 +83,7 @@ require 'scout_apm/instruments/sinatra'
83
83
  require 'scout_apm/instruments/process/process_cpu'
84
84
  require 'scout_apm/instruments/process/process_memory'
85
85
  require 'scout_apm/instruments/percentile_sampler'
86
+ require 'scout_apm/instruments/action_view'
86
87
  require 'allocations'
87
88
 
88
89
  require 'scout_apm/app_server_load'
@@ -143,6 +144,8 @@ require 'scout_apm/middleware'
143
144
 
144
145
  require 'scout_apm/instant/middleware'
145
146
 
147
+ require 'scout_apm/rack'
148
+
146
149
  if defined?(Rails) && defined?(Rails::VERSION) && defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR >= 3 && defined?(Rails::Railtie)
147
150
  module ScoutApm
148
151
  class Railtie < Rails::Railtie
@@ -297,6 +297,7 @@ module ScoutApm
297
297
  end
298
298
  end
299
299
 
300
+ install_instrument(ScoutApm::Instruments::ActionView)
300
301
  install_instrument(ScoutApm::Instruments::ActiveRecord)
301
302
  install_instrument(ScoutApm::Instruments::Moped)
302
303
  install_instrument(ScoutApm::Instruments::Mongoid)
@@ -20,73 +20,78 @@ module ScoutApm
20
20
  # before and after filter timing. Instrumenting Base includes those
21
21
  # filters, at the expense of missing out on controllers that don't use
22
22
  # the full Rails stack.
23
- if defined?(::ActionController) && defined?(::ActionController::Base)
24
- ScoutApm::Agent.instance.logger.info "Instrumenting ActionController::Base"
25
- ::ActionController::Base.class_eval do
26
- # include ScoutApm::Tracer
27
- include ScoutApm::Instruments::ActionControllerRails3Rails4Instruments
23
+ if defined?(::ActionController)
24
+ if defined?(::ActionController::Base)
25
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionController::Base"
26
+ ::ActionController::Base.class_eval do
27
+ # include ScoutApm::Tracer
28
+ include ScoutApm::Instruments::ActionControllerBaseInstruments
29
+ end
28
30
  end
29
- end
30
-
31
- if defined?(::ActionView) && defined?(::ActionView::PartialRenderer)
32
- ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::PartialRenderer"
33
- ::ActionView::PartialRenderer.class_eval do
34
- include ScoutApm::Tracer
35
31
 
36
- instrument_method :render_partial,
37
- :type => "View",
38
- :name => '#{@template.virtual_path rescue "Unknown Partial"}/Rendering',
39
- :scope => true
40
-
41
- instrument_method :collection_with_template,
42
- :type => "View",
43
- :name => '#{@template.virtual_path rescue "Unknown Collection"}/Rendering',
44
- :scope => true
32
+ if defined?(::ActionController::Metal)
33
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionController::Metal"
34
+ ::ActionController::Metal.class_eval do
35
+ include ScoutApm::Instruments::ActionControllerMetalInstruments
36
+ end
45
37
  end
46
38
 
47
- ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::TemplateRenderer"
48
- ::ActionView::TemplateRenderer.class_eval do
49
- include ScoutApm::Tracer
50
- instrument_method :render_template,
51
- :type => "View",
52
- :name => '#{args[0].virtual_path rescue "Unknown"}/Rendering',
53
- :scope => true
39
+ if defined?(::ActionController::API)
40
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionController::Api"
41
+ ::ActionController::API.class_eval do
42
+ include ScoutApm::Instruments::ActionControllerAPIInstruments
43
+ end
54
44
  end
55
45
  end
56
- end
57
- end
58
-
59
- module ActionControllerRails3Rails4Instruments
60
- def process_action(*args)
61
- req = ScoutApm::RequestManager.lookup
62
- req.annotate_request(:uri => scout_transaction_uri(request))
63
-
64
- # IP Spoofing Protection can throw an exception, just move on w/o remote ip
65
- req.context.add_user(:ip => request.remote_ip) rescue nil
66
46
 
67
- req.set_headers(request.headers)
68
-
69
- # Check if this this request is to be reported instantly
70
- if instant_key = request.cookies['scoutapminstant']
71
- Agent.instance.logger.info "Instant trace request with key=#{instant_key} for path=#{path}"
72
- req.instant_key = instant_key
73
- end
74
-
75
- req.web!
47
+ # Returns a new anonymous module each time it is called. So
48
+ # we can insert this multiple times into the ancestors
49
+ # stack. Otherwise it only exists the first time you include it
50
+ # (under Metal, instead of under API) and we miss instrumenting
51
+ # before_action callbacks
52
+ end
76
53
 
77
- req.start_layer( ScoutApm::Layer.new("Controller", "#{controller_path}/#{action_name}") )
78
- begin
79
- super
80
- rescue
81
- req.error!
82
- raise
83
- ensure
84
- req.stop_layer
54
+ def self.build_instrument_module
55
+ Module.new do
56
+ def process_action(*args)
57
+ req = ScoutApm::RequestManager.lookup
58
+ current_layer = req.current_layer
59
+
60
+ # Check if this this request is to be reported instantly
61
+ if instant_key = request.cookies['scoutapminstant']
62
+ Agent.instance.logger.info "Instant trace request with key=#{instant_key} for path=#{path}"
63
+ req.instant_key = instant_key
64
+ end
65
+
66
+ if current_layer.type == "Controller"
67
+ # Don't start a new layer if ActionController::API or ActionController::Base handled it already.
68
+ super
69
+ else
70
+ req.annotate_request(:uri => ScoutApm::Instruments::ActionControllerRails3Rails4.scout_transaction_uri(request))
71
+
72
+ # IP Spoofing Protection can throw an exception, just move on w/o remote ip
73
+ req.context.add_user(:ip => request.remote_ip) rescue nil
74
+ req.set_headers(request.headers)
75
+
76
+ req.web!
77
+
78
+ resolved_name = scout_action_name(*args)
79
+ req.start_layer( ScoutApm::Layer.new("Controller", "#{controller_path}/#{resolved_name}") )
80
+ begin
81
+ super
82
+ rescue
83
+ req.error!
84
+ raise
85
+ ensure
86
+ req.stop_layer
87
+ end
88
+ end
89
+ end
85
90
  end
86
- end # process_action
91
+ end
87
92
 
88
93
  # Given an +ActionDispatch::Request+, formats the uri based on config settings.
89
- def scout_transaction_uri(request)
94
+ def self.scout_transaction_uri(request)
90
95
  case ScoutApm::Agent.instance.config.value("uri_reporting")
91
96
  when 'path'
92
97
  request.path # strips off the query string for more security
@@ -94,8 +99,35 @@ module ScoutApm
94
99
  request.filtered_path
95
100
  end
96
101
  end
102
+ end
97
103
 
98
- end # ActionControllerRails3Rails4Instruments
104
+ module ActionControllerMetalInstruments
105
+ include ScoutApm::Instruments::ActionControllerRails3Rails4.build_instrument_module
106
+
107
+ def scout_action_name(*args)
108
+ action_name = args[0]
109
+ end
110
+ end
111
+
112
+ # Empty, noop module to provide compatibility w/ previous manual instrumentation
113
+ module ActionControllerRails3Rails4Instruments
114
+ end
115
+
116
+ module ActionControllerBaseInstruments
117
+ include ScoutApm::Instruments::ActionControllerRails3Rails4.build_instrument_module
118
+
119
+ def scout_action_name(*args)
120
+ action_name
121
+ end
122
+ end
123
+
124
+ module ActionControllerAPIInstruments
125
+ include ScoutApm::Instruments::ActionControllerRails3Rails4.build_instrument_module
126
+
127
+ def scout_action_name(*args)
128
+ action_name
129
+ end
130
+ end
99
131
  end
100
132
  end
101
133
 
@@ -0,0 +1,49 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ # instrumentation for Rails 3 and Rails 4 is the same.
4
+ class ActionView
5
+ attr_reader :logger
6
+
7
+ def initalize(logger=ScoutApm::Agent.instance.logger)
8
+ @logger = logger
9
+ @installed = false
10
+ end
11
+
12
+ def installed?
13
+ @installed
14
+ end
15
+
16
+ def install
17
+ @installed = true
18
+
19
+ if defined?(::ActionView) && defined?(::ActionView::PartialRenderer)
20
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::PartialRenderer"
21
+ ::ActionView::PartialRenderer.class_eval do
22
+ include ScoutApm::Tracer
23
+
24
+ instrument_method :render_partial,
25
+ :type => "View",
26
+ :name => '#{@template.virtual_path rescue "Unknown Partial"}/Rendering',
27
+ :scope => true
28
+
29
+ instrument_method :collection_with_template,
30
+ :type => "View",
31
+ :name => '#{@template.virtual_path rescue "Unknown Collection"}/Rendering',
32
+ :scope => true
33
+ end
34
+
35
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::TemplateRenderer"
36
+ ::ActionView::TemplateRenderer.class_eval do
37
+ include ScoutApm::Tracer
38
+ instrument_method :render_template,
39
+ :type => "View",
40
+ :name => '#{args[0].virtual_path rescue "Unknown"}/Rendering',
41
+ :scope => true
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+
@@ -0,0 +1,26 @@
1
+ module ScoutApm
2
+ module Rack
3
+ def self.install!
4
+ ScoutApm::Agent.instance.start(:skip_app_server_check => true)
5
+ ScoutApm::Agent.instance.start_background_worker
6
+ end
7
+
8
+ def self.transaction(endpoint_name, env)
9
+ req = ScoutApm::RequestManager.lookup
10
+ req.annotate_request(:uri => env["REQUEST_PATH"]) rescue nil
11
+ req.context.add_user(:ip => env["REMOTE_ADDR"]) rescue nil
12
+
13
+ req.web!
14
+ req.start_layer(ScoutApm::Layer.new('Controller', endpoint_name))
15
+
16
+ begin
17
+ yield
18
+ rescue
19
+ req.error!
20
+ raise
21
+ ensure
22
+ req.stop_layer
23
+ end
24
+ end
25
+ end
26
+ end
@@ -53,7 +53,7 @@ module ScoutApm
53
53
  @error = false
54
54
  @instant_key = nil
55
55
  @mem_start = mem_usage
56
- @dev_trace = ScoutApm::Agent.instance.config.value('dev_trace') && Rails.env.development?
56
+ @dev_trace = ScoutApm::Agent.instance.config.value('dev_trace') && ScoutApm::Agent.instance.environment.env == "development"
57
57
  end
58
58
 
59
59
  def start_layer(layer)
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.1.24"
2
+ VERSION = "2.1.26"
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: 2.1.24
4
+ version: 2.1.26
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: 2017-04-20 00:00:00.000000000 Z
12
+ date: 2017-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -160,6 +160,7 @@ files:
160
160
  - lib/scout_apm/instruments/.DS_Store
161
161
  - lib/scout_apm/instruments/action_controller_rails_2.rb
162
162
  - lib/scout_apm/instruments/action_controller_rails_3_rails4.rb
163
+ - lib/scout_apm/instruments/action_view.rb
163
164
  - lib/scout_apm/instruments/active_record.rb
164
165
  - lib/scout_apm/instruments/elasticsearch.rb
165
166
  - lib/scout_apm/instruments/grape.rb
@@ -198,6 +199,7 @@ files:
198
199
  - lib/scout_apm/platform_integrations/cloud_foundry.rb
199
200
  - lib/scout_apm/platform_integrations/heroku.rb
200
201
  - lib/scout_apm/platform_integrations/server.rb
202
+ - lib/scout_apm/rack.rb
201
203
  - lib/scout_apm/reporter.rb
202
204
  - lib/scout_apm/request_histograms.rb
203
205
  - lib/scout_apm/request_manager.rb