Module: Puppet::Parser::Functions
- Defined in:
- lib/puppet-newrelic.rb
Class Method Summary collapse
- .newfunction_with_newrelic(name, options = {}, &block) ⇒ Object
- .singleton_method_added(method) ⇒ Object
Class Method Details
.newfunction_with_newrelic(name, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/puppet-newrelic.rb', line 20 def self.newfunction_with_newrelic name, = {}, &block newfunction_without_newrelic(name, , &block) func = environment_module.instance_method(:"function_#{name}") environment_module.send(:define_method, :"orig_function_#{name}", func) environment_module.send(:define_method, :"function_#{name}") do |args| ::NewRelic::Agent::MethodTracer.trace_execution_scoped("Custom/PuppetFunction/#{name}") do send(:"orig_function_#{name}", args) end end end |
.singleton_method_added(method) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/puppet-newrelic.rb', line 8 def self.singleton_method_added method return unless method.to_s == "newfunction" return if instance_variable_defined?(:@added) @added = true class << self alias newfunction_without_newrelic newfunction alias newfunction newfunction_with_newrelic end end |