Module: NewRelic::Control::Instrumentation
- Included in:
- NewRelic::Control
- Defined in:
- lib/new_relic/control/instrumentation.rb
Overview
Contains methods that relate to adding and executing files that contain instrumentation for the Ruby Agent
Instance Method Summary collapse
-
#add_instrumentation(pattern) ⇒ Object
Add instrumentation.
-
#install_instrumentation ⇒ Object
Signals the agent that it’s time to actually load the instrumentation files.
- #install_shim ⇒ Object
-
#load_instrumentation_files(pattern) ⇒ Object
Adds a list of files in Dir.glob format (e.g. ‘/app/foo/*/_instrumentation.rb’) This requires the files within a rescue block, so that any errors within instrumentation files do not affect the overall agent or application in which it runs.
Instance Method Details
#add_instrumentation(pattern) ⇒ Object
Add instrumentation. Don’t call this directly. Use NewRelic::Agent#add_instrumentation. This will load the file synchronously if we’ve already loaded the default instrumentation, otherwise instrumentation files specified here will be deferred until all instrumentation is run
This happens after the agent has loaded and all dependencies are ready to be instrumented
36 37 38 39 40 41 42 |
# File 'lib/new_relic/control/instrumentation.rb', line 36 def add_instrumentation(pattern) if @instrumented load_instrumentation_files(pattern) else @instrumentation_files << pattern end end |
#install_instrumentation ⇒ Object
Signals the agent that it’s time to actually load the instrumentation files. May be overridden by subclasses
46 47 48 |
# File 'lib/new_relic/control/instrumentation.rb', line 46 def install_instrumentation _install_instrumentation end |
#install_shim ⇒ Object
25 26 27 |
# File 'lib/new_relic/control/instrumentation.rb', line 25 def install_shim # implemented only in subclasses end |
#load_instrumentation_files(pattern) ⇒ Object
Adds a list of files in Dir.glob format (e.g. ‘/app/foo/*/_instrumentation.rb’) This requires the files within a rescue block, so that any errors within instrumentation files do not affect the overall agent or application in which it runs.
15 16 17 18 19 20 21 22 23 |
# File 'lib/new_relic/control/instrumentation.rb', line 15 def load_instrumentation_files(pattern) Dir.glob(pattern) do |file| begin require file.to_s rescue => e ::NewRelic::Agent.logger.warn("Error loading instrumentation file '#{file}':", e) end end end |