Module: Skylight::Probes::Middleware::InstrumentationExtensions Private

Defined in:
lib/skylight/probes/middleware.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

for Rails >= 6.0, which includes InstrumentationProxy

Instance Method Summary collapse

Instance Method Details

#initialize(middleware, class_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/skylight/probes/middleware.rb', line 6

def initialize(middleware, class_name)
  super

  # NOTE: Caching here leads to better performance, but will not notice if the method is overridden
  # We don't have access to the config here so we can't check whether source locations are enabled.
  # However, this only happens once per middleware so it should be minimal impact.
  @payload[:sk_source_location] = begin
    if middleware.is_a?(Proc)
      middleware.source_location
    elsif middleware.respond_to?(:call)
      middleware.method(:call).source_location
    end
  rescue StandardError
    nil
  end
end