Module: Datadog::Contrib::Patcher::CommonMethods

Defined in:
lib/ddtrace/contrib/patcher.rb

Overview

Prepended instance methods for all patchers

Instance Method Summary collapse

Instance Method Details

#patchObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ddtrace/contrib/patcher.rb', line 24

def patch
  return unless defined?(super)

  do_once(:patch) do
    begin
      super.tap do
        # Emit a metric
        Diagnostics::Health.metrics.instrumentation_patched(1, tags: default_tags)
      end
    rescue StandardError => e
      # Log the error
      Datadog::Logger.log.error("Failed to apply #{patch_name} patch. Cause: #{e} Location: #{e.backtrace.first}")

      # Emit a metric
      tags = default_tags
      tags << "error:#{e.class.name}"

      Diagnostics::Health.metrics.error_instrumentation_patch(1, tags: tags)
    end
  end
end

#patch_nameObject



16
17
18
# File 'lib/ddtrace/contrib/patcher.rb', line 16

def patch_name
  self.class != Class && self.class != Module ? self.class.name : name
end

#patched?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ddtrace/contrib/patcher.rb', line 20

def patched?
  done?(:patch)
end