module Datadog::Contrib::Patcher::CommonMethods
Prepended instance methods for all patchers
Public Instance Methods
on_patch_error(e)
click to toggle source
Processes patching errors. This default implementation logs the error and reports relevant metrics. @param e [Exception]
# File lib/ddtrace/contrib/patcher.rb, line 40 def on_patch_error(e) # Log the error Datadog.logger.error("Failed to apply #{patch_name} patch. Cause: #{e} Location: #{Array(e.backtrace).first}") # Emit a metric tags = default_tags tags << "error:#{e.class.name}" Datadog.health_metrics.error_instrumentation_patch(1, tags: tags) end
patch()
click to toggle source
Calls superclass method
# File lib/ddtrace/contrib/patcher.rb, line 23 def patch return unless defined?(super) patch_only_once.run do begin super.tap do # Emit a metric Datadog.health_metrics.instrumentation_patched(1, tags: default_tags) end rescue StandardError => e on_patch_error(e) end end end
patch_name()
click to toggle source
# File lib/ddtrace/contrib/patcher.rb, line 15 def patch_name self.class != Class && self.class != Module ? self.class.name : name end
patched?()
click to toggle source
# File lib/ddtrace/contrib/patcher.rb, line 19 def patched? patch_only_once.ran? end
Private Instance Methods
patch_only_once()
click to toggle source
# File lib/ddtrace/contrib/patcher.rb, line 59 def patch_only_once # NOTE: This is not thread-safe @patch_only_once ||= Datadog::Utils::OnlyOnce.new end