-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from DataDog/anmarchenko/do_not_start_recorder…
…_when_ci_disabled do not instantiate TestVisibility::Recorder unless CI visibility is enabled
- Loading branch information
Showing
10 changed files
with
485 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "recorder" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
# Special recorder that does not record anything | ||
class NullRecorder | ||
def start_test_session(service: nil, tags: {}) | ||
skip_tracing | ||
end | ||
|
||
def start_test_module(test_module_name, service: nil, tags: {}) | ||
skip_tracing | ||
end | ||
|
||
def start_test_suite(test_suite_name, service: nil, tags: {}) | ||
skip_tracing | ||
end | ||
|
||
def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) | ||
skip_tracing(block) | ||
end | ||
|
||
def trace(span_type, span_name, tags: {}, &block) | ||
skip_tracing(block) | ||
end | ||
|
||
def active_span | ||
end | ||
|
||
def active_test | ||
end | ||
|
||
def active_test_session | ||
end | ||
|
||
def active_test_module | ||
end | ||
|
||
def active_test_suite(test_suite_name) | ||
end | ||
|
||
def deactivate_test(test) | ||
end | ||
|
||
def deactivate_test_session | ||
end | ||
|
||
def deactivate_test_module | ||
end | ||
|
||
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 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Datadog | ||
module CI | ||
module TestVisibility | ||
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 | ||
|
||
def trace: (String span_type, String span_name, ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Span span) -> untyped } -> untyped | ||
|
||
def start_test_session: (?service: String?, ?tags: Hash[untyped, untyped]) -> Datadog::CI::Span | ||
|
||
def start_test_module: (String test_module_name, ?service: String?, ?tags: Hash[untyped, untyped]) -> Datadog::CI::Span | ||
|
||
def start_test_suite: (String test_suite_name, ?service: String?, ?tags: Hash[untyped, untyped]) -> Datadog::CI::Span | ||
|
||
def active_test_session: () -> Datadog::CI::TestSession? | ||
|
||
def active_test_module: () -> Datadog::CI::TestModule? | ||
|
||
def active_test_suite: (String test_suite_name) -> Datadog::CI::TestSuite? | ||
|
||
def active_test: () -> Datadog::CI::Test? | ||
|
||
def active_span: () -> Datadog::CI::Span? | ||
|
||
def deactivate_test: (Datadog::CI::Test test) -> void | ||
|
||
def deactivate_test_session: () -> void | ||
|
||
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 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.