scout_apm 2.1.32 → 2.2.0.pre0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.markdown +2 -161
  4. data/Rakefile +2 -2
  5. data/ext/allocations/allocations.c +0 -6
  6. data/ext/allocations/extconf.rb +0 -1
  7. data/ext/stacks/extconf.rb +33 -0
  8. data/ext/stacks/scout_atomics.h +86 -0
  9. data/ext/stacks/stacks.c +744 -0
  10. data/lib/scout_apm.rb +16 -24
  11. data/lib/scout_apm/agent.rb +38 -93
  12. data/lib/scout_apm/agent/logging.rb +1 -6
  13. data/lib/scout_apm/agent/reporting.rb +6 -8
  14. data/lib/scout_apm/app_server_load.rb +10 -21
  15. data/lib/scout_apm/attribute_arranger.rb +2 -0
  16. data/lib/scout_apm/background_job_integrations/delayed_job.rb +1 -71
  17. data/lib/scout_apm/background_job_integrations/sidekiq.rb +27 -66
  18. data/lib/scout_apm/background_worker.rb +15 -19
  19. data/lib/scout_apm/capacity.rb +57 -0
  20. data/lib/scout_apm/config.rb +29 -135
  21. data/lib/scout_apm/context.rb +5 -9
  22. data/lib/scout_apm/deploy_integrations/capistrano_2.cap +12 -0
  23. data/lib/scout_apm/deploy_integrations/capistrano_2.rb +83 -0
  24. data/lib/scout_apm/deploy_integrations/capistrano_3.cap +12 -0
  25. data/lib/scout_apm/deploy_integrations/capistrano_3.rb +88 -0
  26. data/lib/scout_apm/environment.rb +15 -22
  27. data/lib/scout_apm/histogram.rb +2 -11
  28. data/lib/scout_apm/instant/assets/xmlhttp_instrumentation.html +2 -2
  29. data/lib/scout_apm/instant/middleware.rb +57 -198
  30. data/lib/scout_apm/instruments/action_controller_rails_2.rb +2 -1
  31. data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +59 -90
  32. data/lib/scout_apm/instruments/active_record.rb +5 -7
  33. data/lib/scout_apm/instruments/delayed_job.rb +57 -0
  34. data/lib/scout_apm/instruments/grape.rb +3 -4
  35. data/lib/scout_apm/instruments/middleware_detailed.rb +6 -4
  36. data/lib/scout_apm/instruments/middleware_summary.rb +1 -39
  37. data/lib/scout_apm/instruments/mongoid.rb +3 -24
  38. data/lib/scout_apm/instruments/net_http.rb +2 -7
  39. data/lib/scout_apm/instruments/percentile_sampler.rb +19 -36
  40. data/lib/scout_apm/instruments/process/process_cpu.rb +2 -3
  41. data/lib/scout_apm/instruments/process/process_memory.rb +3 -3
  42. data/lib/scout_apm/layaway.rb +33 -76
  43. data/lib/scout_apm/layer.rb +59 -16
  44. data/lib/scout_apm/layer_converters/converter_base.rb +0 -199
  45. data/lib/scout_apm/layer_converters/job_converter.rb +1 -1
  46. data/lib/scout_apm/layer_converters/metric_converter.rb +1 -1
  47. data/lib/scout_apm/layer_converters/slow_job_converter.rb +90 -15
  48. data/lib/scout_apm/layer_converters/slow_request_converter.rb +101 -13
  49. data/lib/scout_apm/metric_set.rb +1 -9
  50. data/lib/scout_apm/metric_stats.rb +8 -8
  51. data/lib/scout_apm/reporter.rb +15 -51
  52. data/lib/scout_apm/request_histograms.rb +0 -4
  53. data/lib/scout_apm/request_manager.rb +1 -2
  54. data/lib/scout_apm/scored_item_set.rb +0 -7
  55. data/lib/scout_apm/serializers/deploy_serializer.rb +16 -0
  56. data/lib/scout_apm/serializers/payload_serializer.rb +3 -9
  57. data/lib/scout_apm/serializers/payload_serializer_to_json.rb +5 -2
  58. data/lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb +1 -2
  59. data/lib/scout_apm/server_integrations/puma.rb +2 -5
  60. data/lib/scout_apm/slow_item_set.rb +80 -0
  61. data/lib/scout_apm/slow_job_record.rb +1 -6
  62. data/lib/scout_apm/slow_transaction.rb +2 -20
  63. data/lib/scout_apm/store.rb +12 -50
  64. data/lib/scout_apm/trace_compactor.rb +311 -0
  65. data/lib/scout_apm/tracked_request.rb +37 -128
  66. data/lib/scout_apm/utils/backtrace_parser.rb +5 -7
  67. data/lib/scout_apm/utils/fake_stacks.rb +83 -0
  68. data/lib/scout_apm/version.rb +1 -1
  69. data/scout_apm.gemspec +4 -6
  70. data/test/test_helper.rb +0 -56
  71. data/test/unit/config_test.rb +9 -60
  72. data/test/unit/histogram_test.rb +0 -14
  73. data/test/unit/layaway_test.rb +16 -31
  74. data/test/unit/serializers/payload_serializer_test.rb +105 -3
  75. data/test/unit/slow_item_set_test.rb +94 -0
  76. data/test/unit/slow_job_policy_test.rb +49 -0
  77. data/test/unit/slow_request_policy_test.rb +5 -4
  78. data/test/unit/utils/backtrace_parser_test.rb +0 -19
  79. data/tester.rb +53 -0
  80. metadata +29 -124
  81. data/.rubocop.yml +0 -8
  82. data/Guardfile +0 -42
  83. data/ext/rusage/README.md +0 -26
  84. data/ext/rusage/extconf.rb +0 -5
  85. data/ext/rusage/rusage.c +0 -52
  86. data/lib/scout_apm/background_job_integrations/resque.rb +0 -85
  87. data/lib/scout_apm/background_recorder.rb +0 -43
  88. data/lib/scout_apm/debug.rb +0 -37
  89. data/lib/scout_apm/git_revision.rb +0 -51
  90. data/lib/scout_apm/instruments/action_view.rb +0 -49
  91. data/lib/scout_apm/instruments/resque.rb +0 -40
  92. data/lib/scout_apm/layer_children_set.rb +0 -77
  93. data/lib/scout_apm/limited_layer.rb +0 -122
  94. data/lib/scout_apm/rack.rb +0 -26
  95. data/lib/scout_apm/remote/message.rb +0 -23
  96. data/lib/scout_apm/remote/recorder.rb +0 -57
  97. data/lib/scout_apm/remote/router.rb +0 -49
  98. data/lib/scout_apm/remote/server.rb +0 -58
  99. data/lib/scout_apm/serializers/histograms_serializer_to_json.rb +0 -21
  100. data/lib/scout_apm/synchronous_recorder.rb +0 -26
  101. data/lib/scout_apm/utils/gzip_helper.rb +0 -24
  102. data/lib/scout_apm/utils/numbers.rb +0 -14
  103. data/lib/scout_apm/utils/scm.rb +0 -14
  104. data/test/unit/background_job_integrations/sidekiq_test.rb +0 -104
  105. data/test/unit/context_test.rb +0 -30
  106. data/test/unit/git_revision_test.rb +0 -15
  107. data/test/unit/instruments/net_http_test.rb +0 -21
  108. data/test/unit/instruments/percentile_sampler_test.rb +0 -137
  109. data/test/unit/layer_children_set_test.rb +0 -88
  110. data/test/unit/limited_layer_test.rb +0 -53
  111. data/test/unit/remote/test_message.rb +0 -13
  112. data/test/unit/remote/test_router.rb +0 -33
  113. data/test/unit/remote/test_server.rb +0 -15
  114. data/test/unit/store_test.rb +0 -89
  115. data/test/unit/test_tracked_request.rb +0 -87
  116. data/test/unit/utils/numbers_test.rb +0 -15
  117. data/test/unit/utils/scm.rb +0 -17
@@ -48,7 +48,8 @@ module ScoutApm
48
48
  # specific controller actions.
49
49
  def perform_action_with_scout_instruments(*args, &block)
50
50
  req = ScoutApm::RequestManager.lookup
51
- req.annotate_request(:uri => request.path) # for security by-default, we don't use request.fullpath which could reveal filtered params.
51
+ path = ScoutApm::Agent.instance.config.value("uri_reporting") == 'path' ? request.path : request.fullpath
52
+ req.annotate_request(:uri => path)
52
53
  req.context.add_user(:ip => request.remote_ip)
53
54
  req.set_headers(request.headers)
54
55
  req.start_layer( ScoutApm::Layer.new("Controller", "#{controller_path}/#{action_name}") )
@@ -20,112 +20,81 @@ 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)
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
30
- end
31
-
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
37
- end
38
-
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
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
44
28
  end
29
+ ScoutApm::Agent.instance.logger.info "Installing ScoutProf profiling" if ScoutApm::Agent.instance.config.value('profile')
45
30
  end
46
31
 
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
32
+ if defined?(::ActionView) && defined?(::ActionView::PartialRenderer)
33
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::PartialRenderer"
34
+ ::ActionView::PartialRenderer.class_eval do
35
+ include ScoutApm::Tracer
53
36
 
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 && 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
37
+ instrument_method :render_partial,
38
+ :type => "View",
39
+ :name => '#{@template.virtual_path rescue "Unknown Partial"}/Rendering',
40
+ :scope => true
41
+
42
+ instrument_method :collection_with_template,
43
+ :type => "View",
44
+ :name => '#{@template.virtual_path rescue "Unknown Collection"}/Rendering',
45
+ :scope => true
89
46
  end
90
- end
91
- end
92
47
 
93
- # Given an +ActionDispatch::Request+, formats the uri based on config settings.
94
- def self.scout_transaction_uri(request)
95
- case ScoutApm::Agent.instance.config.value("uri_reporting")
96
- when 'path'
97
- request.path # strips off the query string for more security
98
- else # default handles filtered params
99
- request.filtered_path
48
+ ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::TemplateRenderer"
49
+ ::ActionView::TemplateRenderer.class_eval do
50
+ include ScoutApm::Tracer
51
+ instrument_method :render_template,
52
+ :type => "View",
53
+ :name => '#{args[0].virtual_path rescue "Unknown"}/Rendering',
54
+ :scope => true
55
+ end
100
56
  end
101
57
  end
102
58
  end
103
59
 
104
- module ActionControllerMetalInstruments
105
- include ScoutApm::Instruments::ActionControllerRails3Rails4.build_instrument_module
60
+ module ActionControllerRails3Rails4Instruments
61
+ def process_action(*args)
62
+ req = ScoutApm::RequestManager.lookup
63
+ path = ScoutApm::Agent.instance.config.value("uri_reporting") == 'path' ? request.path : request.fullpath
64
+ req.annotate_request(:uri => path)
65
+
66
+ # IP Spoofing Protection can throw an exception, just move on w/o remote ip
67
+ req.context.add_user(:ip => request.remote_ip) rescue nil
106
68
 
107
- def scout_action_name(*args)
108
- action_name = args[0]
109
- end
110
- end
69
+ req.set_headers(request.headers)
111
70
 
112
- # Empty, noop module to provide compatibility w/ previous manual instrumentation
113
- module ActionControllerRails3Rails4Instruments
114
- end
71
+ # Check if this this request is to be reported instantly
72
+ if instant_key = request.cookies['scoutapminstant']
73
+ Agent.instance.logger.info "Instant trace request with key=#{instant_key} for path=#{path}"
74
+ req.instant_key = instant_key
75
+ end
115
76
 
116
- module ActionControllerBaseInstruments
117
- include ScoutApm::Instruments::ActionControllerRails3Rails4.build_instrument_module
77
+ req.web!
118
78
 
119
- def scout_action_name(*args)
120
- action_name
121
- end
122
- end
79
+ layer = ScoutApm::Layer.new("Controller", "#{controller_path}/#{action_name}")
123
80
 
124
- module ActionControllerAPIInstruments
125
- include ScoutApm::Instruments::ActionControllerRails3Rails4.build_instrument_module
81
+ if ScoutApm::Agent.instance.config.value('profile')
82
+ # Capture ScoutProf if we can
83
+ req.enable_profiled_thread!
84
+ layer.set_root_class(self.class)
85
+ layer.traced!
86
+ end
126
87
 
127
- def scout_action_name(*args)
128
- action_name
88
+ # Start the layer, then execute the user's code
89
+ req.start_layer(layer)
90
+ begin
91
+ super
92
+ rescue
93
+ req.error!
94
+ raise
95
+ ensure
96
+ req.stop_layer
97
+ end
129
98
  end
130
99
  end
131
100
  end
@@ -62,10 +62,8 @@ module ScoutApm
62
62
  layer = req.current_layer
63
63
  if layer && layer.type == "ActiveRecord"
64
64
  layer.annotate_layer(payload)
65
- elsif layer
66
- ScoutApm::Agent.instance.logger.debug("Expected layer type: ActiveRecord, got #{layer && layer.type}")
67
65
  else
68
- # noop, no layer at all. We're probably ignoring this req.
66
+ ScoutApm::Agent.instance.logger.debug("Expected layer type: ActiveRecord, got #{layer && layer.type}")
69
67
  end
70
68
  end
71
69
  end
@@ -122,7 +120,7 @@ module ScoutApm
122
120
  current_layer.desc = desc
123
121
  end
124
122
 
125
- log_without_scout_instruments(*args, &block)
123
+ log_without_scout_instruments(sql, name, &block)
126
124
 
127
125
  # OR: Start a new layer, we didn't pick up instrumentation earlier in the stack.
128
126
  else
@@ -130,7 +128,7 @@ module ScoutApm
130
128
  layer.desc = desc
131
129
  req.start_layer(layer)
132
130
  begin
133
- log_without_scout_instruments(*args, &block)
131
+ log_without_scout_instruments(sql, name, &block)
134
132
  ensure
135
133
  req.stop_layer
136
134
  end
@@ -175,7 +173,7 @@ module ScoutApm
175
173
  req.start_layer(layer)
176
174
  req.ignore_children!
177
175
  begin
178
- find_by_sql_without_scout_instruments(*args, &block)
176
+ find_by_sql_without_scout_instruments(*args)
179
177
  ensure
180
178
  req.acknowledge_children!
181
179
  req.stop_layer
@@ -201,7 +199,7 @@ module ScoutApm
201
199
  req.start_layer(layer)
202
200
  req.ignore_children!
203
201
  begin
204
- find_with_associations_without_scout_instruments(*args, &block)
202
+ find_with_associations_without_scout_instruments(*args)
205
203
  ensure
206
204
  req.acknowledge_children!
207
205
  req.stop_layer
@@ -0,0 +1,57 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class DelayedJob
4
+ attr_reader :logger
5
+
6
+ def initialize(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
+ if defined?(::Delayed::Worker)
18
+ ::Delayed::Worker.class_eval do
19
+ include ScoutApm::Tracer
20
+ include ScoutApm::Instruments::DelayedJobInstruments
21
+ alias run_without_scout_instruments run
22
+ alias run run_with_scout_instruments
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ module DelayedJobInstruments
29
+ def run_with_scout_instruments(job)
30
+ scout_method_name = method_from_handler(job.handler)
31
+ queue = job.queue
32
+ latency = (Time.now.to_f - job.created_at.to_f) * 1000
33
+
34
+ ScoutApm::Agent.instance.store.track_one!("Queue", queue, 0, {:extra_metrics => {:latency => latency}})
35
+ req = ScoutApm::RequestManager.lookup
36
+ req.job!
37
+ req.start_layer( ScoutApm::Layer.new("Job", scout_method_name) )
38
+
39
+ begin
40
+ run_without_scout_instruments(job)
41
+ rescue
42
+ req.error!
43
+ raise
44
+ ensure
45
+ req.stop_layer
46
+ end
47
+ end
48
+
49
+ def method_from_handler(handler)
50
+ job_handler = YAML.load(handler)
51
+ klass = job_handler.object.name
52
+ method = job_handler.method_name
53
+ "#{klass}##{method}"
54
+ end
55
+ end
56
+ end
57
+ end
@@ -29,10 +29,9 @@ module ScoutApm
29
29
  end
30
30
 
31
31
  module GrapeEndpointInstruments
32
- def run_with_scout_instruments(*args)
33
- request = ::Grape::Request.new(env || args.first)
32
+ def run_with_scout_instruments
33
+ request = ::Grape::Request.new(env)
34
34
  req = ScoutApm::RequestManager.lookup
35
-
36
35
  path = ScoutApm::Agent.instance.config.value("uri_reporting") == 'path' ? request.path : request.fullpath
37
36
  req.annotate_request(:uri => path)
38
37
 
@@ -56,7 +55,7 @@ module ScoutApm
56
55
 
57
56
  req.start_layer( ScoutApm::Layer.new("Controller", name) )
58
57
  begin
59
- run_without_scout_instruments(*args)
58
+ run_without_scout_instruments
60
59
  rescue
61
60
  req.error!
62
61
  raise
@@ -1,11 +1,13 @@
1
1
  # Inserts a new middleware between each actual middleware in the application,
2
2
  # so as to trace the time for each one.
3
3
  #
4
- # Currently disabled by default due to the overhead of this approach (~10-15ms
5
- # per request in practice). Instead, middleware as a whole are instrumented
6
- # via the MiddlewareSummary class.
4
+ # Currently disabled due to the overhead of this approach (~10-15ms per request
5
+ # in practice). Instead, middleware as a whole are instrumented via the
6
+ # MiddlewareSummary class.
7
7
  #
8
- # Turn this on with the configuration setting `detailed_middleware` set to true
8
+ # There will likely be a configuration flag to turn this on in favor of the
9
+ # summary tracing in a future version of the agent, but this is not yet
10
+ # implemented.
9
11
  module ScoutApm
10
12
  module Instruments
11
13
  class MiddlewareDetailed
@@ -23,15 +23,7 @@ module ScoutApm
23
23
  ActionDispatch::MiddlewareStack.class_eval do
24
24
  def build_with_scout_instruments(app = nil, &block)
25
25
  mw_stack = build_without_scout_instruments(app) { block.call if block }
26
- if app == mw_stack
27
- # Return the raw middleware stack if it equaled app. No
28
- # middlewares were created, so nothing to wrap & test.
29
- #
30
- # Avoids instrumentation of something that doesn't exist
31
- mw_stack
32
- else
33
- MiddlewareSummaryWrapper.new(mw_stack)
34
- end
26
+ MiddlewareSummaryWrapper.new(mw_stack)
35
27
  end
36
28
 
37
29
  alias_method :build_without_scout_instruments, :build
@@ -53,36 +45,6 @@ module ScoutApm
53
45
  ensure
54
46
  req.stop_layer
55
47
  end
56
-
57
- # Some code (found in resque_web initially) attempts to call methods
58
- # directly on `MyApplication.app`, which is the middleware stack.
59
- # If it hits our middleware instead of the object at the root of the
60
- # app that it expected, then a method it expects will not be there, and an
61
- # error thrown.
62
- #
63
- # Specifically, resque_web assumes `ResqueWeb::Engine.app.url_helpers`
64
- # is a method call on rails router for its own Engine, when in fact,
65
- # we've added a middleware before it.
66
- #
67
- # So method_missing just proxies anything to the nested @app object
68
- #
69
- # While method_missing is not very performant, this is only here to
70
- # handle edge-cases in other code, and should not be regularly called
71
- def method_missing(sym, *arguments, &block)
72
- if @app.respond_to?(sym)
73
- @app.send(sym, *arguments, &block)
74
- else
75
- super
76
- end
77
- end
78
-
79
- def respond_to?(sym, include_private = false)
80
- if @app.respond_to?(sym, include_private)
81
- true
82
- else
83
- super
84
- end
85
- end
86
48
  end
87
49
  end
88
50
  end
@@ -32,8 +32,8 @@ module ScoutApm
32
32
  ### See moped instrument for Moped driven deploys
33
33
 
34
34
  ### 5.x Mongoid
35
- if (mongoid_v5? || mongoid_v6?) && defined?(::Mongoid::Contextual::Mongo)
36
- ScoutApm::Agent.instance.logger.info "Instrumenting Mongoid 5.x/6.x"
35
+ if mongoid_v5? && defined?(::Mongoid::Contextual::Mongo)
36
+ ScoutApm::Agent.instance.logger.info "Instrumenting Mongoid 5.x"
37
37
  # All the public methods from Mongoid::Contextual::Mongo.
38
38
  # TODO: Geo and MapReduce support (?). They are in other Contextual::* classes
39
39
  methods = [
@@ -50,24 +50,11 @@ module ScoutApm
50
50
  with_scout_instruments = %Q[
51
51
  def #{method}_with_scout_instruments(*args, &block)
52
52
 
53
-
54
53
  req = ScoutApm::RequestManager.lookup
55
54
  *db, collection = view.collection.namespace.split(".")
56
55
 
57
56
  name = collection + "/#{method}"
58
-
59
- # Between Mongo gem version 2.1 and 2.3, this method name was
60
- # changed. Accomodate both. If for some reason neither is
61
- # there, try to continue with an empty "filter" hash.
62
- raw_filter = if view.respond_to?(:selector)
63
- view.selector
64
- elsif view.respond_to?(:filter)
65
- view.filter
66
- else
67
- {}
68
- end
69
-
70
- filter = ScoutApm::Instruments::Mongoid.anonymize_filter(raw_filter)
57
+ filter = ScoutApm::Instruments::Mongoid.anonymize_filter(view.filter)
71
58
 
72
59
  layer = ScoutApm::Layer.new("MongoDB", name)
73
60
  layer.desc = filter.inspect
@@ -99,14 +86,6 @@ module ScoutApm
99
86
  end
100
87
  end
101
88
 
102
- def mongoid_v6?
103
- if defined?(::Mongoid::VERSION)
104
- ::Mongoid::VERSION =~ /\A6/
105
- else
106
- false
107
- end
108
- end
109
-
110
89
 
111
90
  # Example of what a filter looks like: => {"founded"=>{"$gte"=>"1980-1-1"}, "name"=>{"$in"=>["Tool", "Deftones", "Melvins"]}}
112
91
  # Approach: find every leaf-node, clear it. inspect the whole thing when done.
@@ -22,17 +22,12 @@ module ScoutApm
22
22
  include ScoutApm::Tracer
23
23
 
24
24
  def request_with_scout_instruments(*args,&block)
25
- self.class.instrument("HTTP", "request", :desc => request_scout_description(args.first)) do
25
+ url = (@address + args.first.path.split('?').first)[0..99]
26
+ self.class.instrument("HTTP", "request", :desc => url) do
26
27
  request_without_scout_instruments(*args, &block)
27
28
  end
28
29
  end
29
30
 
30
- def request_scout_description(req)
31
- path = req.path
32
- path = path.path if path.respond_to?(:path)
33
- (@address + path.split('?').first)[0..99]
34
- end
35
-
36
31
  alias request_without_scout_instruments request
37
32
  alias request request_with_scout_instruments
38
33
  end