Skip to content

Commit

Permalink
remove inheritance from NullRecorder to make sure that there are no s…
Browse files Browse the repository at this point in the history
…ide effects in the future
  • Loading branch information
anmarchenko committed Dec 12, 2023
1 parent 84a5bf8 commit bc69135
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
20 changes: 15 additions & 5 deletions lib/datadog/ci/test_visibility/null_recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ module Datadog
module CI
module TestVisibility
# Special recorder that does not record anything
#
class NullRecorder < Recorder
def initialize(*)
end

class NullRecorder
def start_test_session(service: nil, tags: {})
skip_tracing
end
Expand Down Expand Up @@ -57,6 +53,20 @@ def deactivate_test_module

def deactivate_test_suite(test_suite_name)
end

private

def skip_tracing(block = nil)
if block
block.call(null_span)
else
null_span
end
end

def null_span
@null_span ||= NullSpan.new
end
end
end
end
Expand Down
10 changes: 9 additions & 1 deletion sig/datadog/ci/test_visibility/null_recorder.rbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module Datadog
module CI
module TestVisibility
class NullRecorder < Recorder
class NullRecorder
@null_span: Datadog::CI::NullSpan

def initialize: (?untyped args) -> void

def trace_test: (String span_name, String test_suite_name, ?service: String?, ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Span span) -> untyped } -> untyped
Expand Down Expand Up @@ -31,6 +33,12 @@ module Datadog
def deactivate_test_module: () -> void

def deactivate_test_suite: (String test_suite_name) -> void

private

def null_span: () -> Datadog::CI::Span

def skip_tracing: (?untyped block) -> untyped
end
end
end
Expand Down

0 comments on commit bc69135

Please sign in to comment.