Module: TingYun::Frameworks::Instrumentation
- Included in:
- InstanceMethods
- Defined in:
- lib/ting_yun/frameworks/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
- #detect_dependencies ⇒ Object
-
#install_instrumentation ⇒ Object
Signals the agent that it’s time to actually load the instrumentation files.
-
#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
19 20 21 22 23 24 25 |
# File 'lib/ting_yun/frameworks/instrumentation.rb', line 19 def add_instrumentation(pattern) if @instrumented load_instrumentation_files pattern else @instrumentation_files << pattern end end |
#detect_dependencies ⇒ Object
47 48 49 |
# File 'lib/ting_yun/frameworks/instrumentation.rb', line 47 def detect_dependencies LibraryDetection.detect! end |
#install_instrumentation ⇒ Object
Signals the agent that it’s time to actually load the instrumentation files. May be overridden by subclasses
14 15 16 |
# File 'lib/ting_yun/frameworks/instrumentation.rb', line 14 def install_instrumentation _install_instrumentation 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ting_yun/frameworks/instrumentation.rb', line 32 def load_instrumentation_files(pattern) Dir.glob(pattern) do |file| begin if file.to_s.include?('instrumentation/kafka.rb') # (**options) will report syntax error when ruby version under 2.0.0 require file.to_s if (defined? RUBY_VERSION) && (TingYun::Support::VersionNumber.new(RUBY_VERSION) >= TingYun::Support::VersionNumber.new('2.0.0'.freeze)) else require file.to_s end rescue LoadError => e TingYun::Agent.logger.warn "Error loading instrumentation file '#{file}':", e end end end |