Skip to content

Commit

Permalink
Integration#patch method now always returns Hash
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Nov 15, 2024
1 parent a879e6a commit b17763c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/datadog/ci/contrib/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def self.instrument(integration_name, options = {}, &block)
return unless integration.enabled

patch_results = integration.patch
if patch_results == true
if patch_results[:ok]
# try to patch dependant integrations (for example knapsack that depends on rspec)
dependants = integration.dependants
.map { |name| fetch_integration(name) }
Expand Down Expand Up @@ -62,7 +62,7 @@ def self.instrument_on_session_start
Datadog.logger.debug "#{name} is allowed to be late instrumented"

patch_results = integration.patch
if patch_results == true
if patch_results[:ok]
Datadog.logger.debug("#{name} is patched")
else
Datadog.logger.debug("#{name} is not patched (#{patch_results})")
Expand Down
3 changes: 2 additions & 1 deletion lib/datadog/ci/contrib/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def patch
patcher_klass = patcher
if !patchable? || patcher_klass.nil?
return {
ok: false,
available: available?,
loaded: loaded?,
compatible: compatible?,
Expand All @@ -105,7 +106,7 @@ def patch
end

patcher_klass.patch
true
{ok: true}
end

# Can the patch for this integration be applied automatically?
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/ci/contrib/integration.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Datadog

def patcher: () -> Datadog::Tracing::Contrib::Patcher?

def patch: () -> (bool | Hash[Symbol, bool])
def patch: () -> Hash[Symbol, bool]

def late_instrument?: () -> bool

Expand Down
12 changes: 5 additions & 7 deletions sig/datadog/ci/contrib/patcher.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module Datadog
module CI
module Contrib
module Patcher
def self.included: (untyped base) -> untyped
def self.included: (Class base) -> void

module CommonMethods
attr_accessor patch_error_result: untyped
attr_accessor patch_error_result: Hash[Symbol, untyped]

attr_accessor patch_successful: untyped
attr_accessor patch_successful: bool

def patch_name: () -> String?

Expand All @@ -17,13 +17,11 @@ module Datadog

def patch: () -> void

def on_patch_error: (untyped e) -> untyped

def default_tags: () -> untyped
def on_patch_error: (StandardError e) -> Hash[Symbol, untyped]

private

def patch_only_once: () -> untyped
def patch_only_once: () -> Datadog::Core::Utils::OnlyOnce

@patch_only_once: Datadog::Core::Utils::OnlyOnce
end
Expand Down

0 comments on commit b17763c

Please sign in to comment.