Module: NewRelic::Agent::Instrumentation::Rack::Prepend

Includes:
NewRelic::Agent::Instrumentation::RackBuilder
Defined in:
lib/new_relic/agent/instrumentation/rack/prepend.rb

Constant Summary

Constants included from NewRelic::Agent::Instrumentation::RackBuilder

NewRelic::Agent::Instrumentation::RackBuilder::INSTRUMENTATION_NAME

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NewRelic::Agent::Instrumentation::RackBuilder

#check_for_late_instrumentation, #deferred_dependency_check, #middleware_instrumentation_enabled?, #run_with_tracing, track_deferred_detection, #use_with_tracing, #with_deferred_dependency_detection

Class Method Details

.prepended(builder_class) ⇒ Object



18
19
20
# File 'lib/new_relic/agent/instrumentation/rack/prepend.rb', line 18

def self.prepended(builder_class)
  NewRelic::Agent::Instrumentation::RackBuilder.track_deferred_detection(builder_class)
end

Instance Method Details

#run(app = nil, *args, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/new_relic/agent/instrumentation/rack/prepend.rb', line 26

def run(app = nil, *args, &block)
  app_or_block = app || block
  run_with_tracing(app_or_block) do |wrapped|
    # Rack::Builder#run for Rack v3+ supports a block, and does not
    # support args. Whether a block or an app is provided, that callable
    # object will be wrapped into a MiddlewareProxy instance. That
    # proxy instance must then be passed to super as the app argument.
    block ? super(wrapped, &nil) : super(wrapped, *args)
  end
end

#to_appObject



22
23
24
# File 'lib/new_relic/agent/instrumentation/rack/prepend.rb', line 22

def to_app
  with_deferred_dependency_detection { super }
end

#use(middleware_class, *args, &blk) ⇒ Object



37
38
39
# File 'lib/new_relic/agent/instrumentation/rack/prepend.rb', line 37

def use(middleware_class, *args, &blk)
  use_with_tracing(middleware_class) { |wrapped_class| super(wrapped_class, *args, &blk) }
end