Skip to content

Commit fb26fae

Browse files
committed
fix loaded? definitions for integrations; do not patch already patched integrations
1 parent 88a1837 commit fb26fae

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

lib/datadog/ci/contrib/cucumber/integration.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def version
1717
end
1818

1919
def loaded?
20-
!defined?(::Cucumber).nil? && !defined?(::Cucumber::Runtime).nil?
20+
!defined?(::Cucumber).nil? && !defined?(::Cucumber::Runtime).nil? && !defined?(::Cucumber::Configuration).nil?
2121
end
2222

2323
def compatible?

lib/datadog/ci/contrib/instrumentation.rb

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def self.auto_instrument
4646

4747
script_compiled_tracepoint = TracePoint.new(:script_compiled) do
4848
auto_instrumented_integrations.each do |integration|
49+
next if integration.patched?
4950
next unless integration.loaded?
5051

5152
Datadog.logger.debug("#{integration.class} is loaded")

lib/datadog/ci/contrib/integration.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ def patcher
9393

9494
# @!visibility private
9595
def patch
96-
# @type var patcher_klass: untyped
97-
patcher_klass = patcher
98-
if !patchable? || patcher_klass.nil?
96+
if !patchable? || patcher.nil?
9997
return {
10098
ok: false,
10199
available: available?,
@@ -105,10 +103,14 @@ def patch
105103
}
106104
end
107105

108-
patcher_klass.patch
106+
patcher.patch
109107
{ok: true}
110108
end
111109

110+
def patched?
111+
patcher&.patched?
112+
end
113+
112114
# Can the patch for this integration be applied automatically?
113115
# @return [Boolean] can the tracer activate this instrumentation without explicit user input?
114116
def late_instrument?

lib/datadog/ci/contrib/minitest/integration.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def version
1717
end
1818

1919
def loaded?
20-
!defined?(::Minitest).nil?
20+
!defined?(::Minitest).nil? && !defined?(::Minitest::Runnable).nil? && !defined?(::Minitest::Test).nil? &&
21+
!defined?(::Minitest::CompositeReporter).nil?
2122
end
2223

2324
def compatible?

lib/datadog/ci/contrib/rspec/integration.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def version
2222

2323
def loaded?
2424
!defined?(::RSpec).nil? && !defined?(::RSpec::Core).nil? &&
25-
!defined?(::RSpec::Core::Example).nil?
25+
!defined?(::RSpec::Core::Example).nil? &&
26+
!defined?(::RSpec::Core::Runner).nil? &&
27+
!defined?(::RSpec::Core::ExampleGroup).nil?
2628
end
2729

2830
def compatible?

sig/datadog/ci/contrib/integration.rbs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ module Datadog
2020

2121
def enabled: () -> bool
2222

23-
def patcher: () -> Datadog::Tracing::Contrib::Patcher?
23+
def patcher: () -> untyped
24+
25+
def patched?: () -> bool?
2426

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

0 commit comments

Comments
 (0)