Class: ScoutApm::Instruments::Sinatra

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/instruments/sinatra.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/scout_apm/instruments/sinatra.rb', line 5

def logger
  @logger
end

Instance Method Details

#initalize(logger = ScoutApm::Agent.instance.context.logger) ⇒ Object



7
8
9
10
# File 'lib/scout_apm/instruments/sinatra.rb', line 7

def initalize(logger=ScoutApm::Agent.instance.context.logger)
  @logger = logger
  @installed = false
end

#installObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/scout_apm/instruments/sinatra.rb', line 16

def install
  if defined?(::Sinatra) && defined?(::Sinatra::Base) && ::Sinatra::Base.private_method_defined?(:dispatch!)
    @installed = true

    logger.info "Instrumenting Sinatra"
    ::Sinatra::Base.class_eval do
      include ScoutApm::Tracer
      include ScoutApm::Instruments::SinatraInstruments
      alias dispatch_without_scout_instruments! dispatch!
      alias dispatch! dispatch_with_scout_instruments!
    end
  end
end

#installed?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/scout_apm/instruments/sinatra.rb', line 12

def installed?
  @installed
end