Module: Skylight::Probes::Middleware::Probe::InstanceInstrumentation Private

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

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.

Instance Method Summary collapse

Instance Method Details

#__has_sk__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.



108
109
110
# File 'lib/skylight/probes/middleware.rb', line 108

def __has_sk__
  true
end

#__sk_categoryObject

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.



104
105
106
# File 'lib/skylight/probes/middleware.rb', line 104

def __sk_category
  "rack.middleware"
end

#__sk_default_nameObject

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.



100
101
102
# File 'lib/skylight/probes/middleware.rb', line 100

def __sk_default_name
  "Anonymous Middleware"
end

#call(*args) ⇒ 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.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/skylight/probes/middleware.rb', line 61

def call(*args)
  return super(*args) if Skylight::Probes::Middleware::Probe.disabled?

  trace = Skylight.instrumenter&.current_trace
  return super(*args) unless trace

  begin
    name = self.class.name || __sk_default_name

    trace.endpoint = name

    source_file, source_line = method(__method__).super_method.source_location

    spans =
      Skylight.instrument(
        title: name,
        category: __sk_category,
        source_file: source_file,
        source_line: source_line
      )

    proxied_response =
      Skylight::Middleware.with_after_close(super(*args), debug_identifier: "Middleware: #{name}") do
        Skylight.done(spans)
      end
  rescue Exception => e
    Skylight.done(spans, exception_object: e)
    raise
  ensure
    unless e || proxied_response
      # If we've gotten to this point, the most likely scenario is that
      # a throw/catch has bypassed a portion of the callstack. Since these spans would not otherwise
      # be closed, mark them deferred to indicate that they should be implicitly closed.
      # See Trace#deferred_spans or Trace#stop for more information.
      Skylight.done(spans, defer: true)
    end
  end
end