Module: Datadog::CI::Contrib::Patcher::CommonMethods
- Defined in:
- lib/datadog/ci/contrib/patcher.rb
Overview
Prepended instance methods for all patchers
Instance Attribute Summary collapse
-
#patch_error_result ⇒ Object
Returns the value of attribute patch_error_result.
-
#patch_successful ⇒ Object
Returns the value of attribute patch_successful.
Instance Method Summary collapse
-
#on_patch_error(e) ⇒ Object
Processes patching errors.
- #patch ⇒ Object
- #patch_name ⇒ Object
- #patched? ⇒ Boolean
Instance Attribute Details
#patch_error_result ⇒ Object
Returns the value of attribute patch_error_result.
16 17 18 |
# File 'lib/datadog/ci/contrib/patcher.rb', line 16 def patch_error_result @patch_error_result end |
#patch_successful ⇒ Object
Returns the value of attribute patch_successful.
16 17 18 |
# File 'lib/datadog/ci/contrib/patcher.rb', line 16 def patch_successful @patch_successful end |
Instance Method Details
#on_patch_error(e) ⇒ Object
Processes patching errors. This default implementation logs the error and reports relevant metrics.
42 43 44 45 46 47 48 49 50 |
# File 'lib/datadog/ci/contrib/patcher.rb', line 42 def on_patch_error(e) Datadog.logger.error("Failed to apply #{patch_name} patch. Cause: #{e} Location: #{Array(e.backtrace).first}") @patch_error_result = { type: e.class.name, message: e., line: Array(e.backtrace).first } end |
#patch ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/ci/contrib/patcher.rb', line 28 def patch return unless defined?(super) patch_only_once.run do super.tap do @patch_successful = true end rescue => e on_patch_error(e) end end |
#patch_name ⇒ Object
20 21 22 |
# File 'lib/datadog/ci/contrib/patcher.rb', line 20 def patch_name (self.class != Class && self.class != Module) ? self.class.name : name end |
#patched? ⇒ Boolean
24 25 26 |
# File 'lib/datadog/ci/contrib/patcher.rb', line 24 def patched? patch_only_once.ran? end |