Module: Skylight::Probes::Sinatra::Instrumentation Private

Defined in:
lib/skylight/probes/sinatra.rb,
lib/skylight/probes/sinatra_add_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

#compile_template(engine, data, options) ⇒ 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.



39
40
41
42
43
44
45
46
47
48
# File 'lib/skylight/probes/sinatra.rb', line 39

def compile_template(engine, data, options, *)
  super.tap do |template|
    if defined?(::Tilt::Template) && template.is_a?(::Tilt::Template)
      # Pass along a useful "virtual path" to Tilt. The Tilt probe will handle
      # instrumenting correctly.
      virtual_path = data.is_a?(Symbol) ? data.to_s : "Inline template (#{engine})"
      template.instance_variable_set(:@__sky_virtual_path, virtual_path)
    end
  end
end

#dispatch!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.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/skylight/probes/sinatra.rb', line 22

def dispatch!(*)
  super.tap do
    if (trace = Skylight.instrumenter&.current_trace) && (route = env["sinatra.route"])
      # Include the app's mount point (if available)
      script_name = trace.instrumenter.config.sinatra_route_prefixes? && env["SCRIPT_NAME"]

      trace.endpoint =
        if script_name && !script_name.empty?
          verb, path = route.split(" ", 2)
          "#{verb} [#{script_name}]#{path}"
        else
          route
        end
    end
  end
end

#setup_default_middleware(builder) ⇒ 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.



5
6
7
8
# File 'lib/skylight/probes/sinatra_add_middleware.rb', line 5

def setup_default_middleware(builder)
  builder.use Skylight::Middleware
  super
end