Module: Datadog::CI
- Defined in:
- lib/datadog/ci.rb,
lib/datadog/ci/span.rb,
lib/datadog/ci/test.rb,
lib/datadog/ci/worker.rb,
lib/datadog/ci/cli/cli.rb,
lib/datadog/ci/ext/git.rb,
lib/datadog/ci/ext/rum.rb,
lib/datadog/ci/git/cli.rb,
lib/datadog/ci/version.rb,
lib/datadog/ci/ext/test.rb,
lib/datadog/ci/git/diff.rb,
lib/datadog/ci/git/user.rb,
lib/datadog/ci/utils/git.rb,
lib/datadog/ci/utils/rum.rb,
lib/datadog/ci/test_suite.rb,
lib/datadog/ci/test_module.rb,
lib/datadog/ci/async_writer.rb,
lib/datadog/ci/ext/settings.rb,
lib/datadog/ci/test_session.rb,
lib/datadog/ci/utils/bundle.rb,
lib/datadog/ci/ext/app_types.rb,
lib/datadog/ci/ext/telemetry.rb,
lib/datadog/ci/ext/transport.rb,
lib/datadog/ci/git/packfiles.rb,
lib/datadog/ci/git/telemetry.rb,
lib/datadog/ci/utils/command.rb,
lib/datadog/ci/utils/parsing.rb,
lib/datadog/ci/logs/component.rb,
lib/datadog/ci/logs/transport.rb,
lib/datadog/ci/transport/gzip.rb,
lib/datadog/ci/transport/http.rb,
lib/datadog/ci/utils/stateful.rb,
lib/datadog/ci/utils/test_run.rb,
lib/datadog/ci/codeowners/rule.rb,
lib/datadog/ci/concurrent_span.rb,
lib/datadog/ci/contrib/patcher.rb,
lib/datadog/ci/ext/environment.rb,
lib/datadog/ci/utils/telemetry.rb,
lib/datadog/ci/cli/command/base.rb,
lib/datadog/ci/cli/command/exec.rb,
lib/datadog/ci/contrib/settings.rb,
lib/datadog/ci/remote/component.rb,
lib/datadog/ci/codeowners/parser.rb,
lib/datadog/ci/contrib/rspec/ext.rb,
lib/datadog/ci/git/changed_lines.rb,
lib/datadog/ci/git/tree_uploader.rb,
lib/datadog/ci/utils/source_code.rb,
lib/datadog/ci/codeowners/matcher.rb,
lib/datadog/ci/ext/test_discovery.rb,
lib/datadog/ci/git/search_commits.rb,
lib/datadog/ci/transport/api/base.rb,
lib/datadog/ci/utils/file_storage.rb,
lib/datadog/ci/contrib/cuprite/ext.rb,
lib/datadog/ci/contrib/integration.rb,
lib/datadog/ci/contrib/lograge/ext.rb,
lib/datadog/ci/git/upload_packfile.rb,
lib/datadog/ci/transport/telemetry.rb,
lib/datadog/ci/utils/configuration.rb,
lib/datadog/ci/contrib/cucumber/ext.rb,
lib/datadog/ci/contrib/minitest/ext.rb,
lib/datadog/ci/contrib/rspec/runner.rb,
lib/datadog/ci/contrib/selenium/ext.rb,
lib/datadog/ci/git/local_repository.rb,
lib/datadog/ci/readonly_test_module.rb,
lib/datadog/ci/contrib/minitest/test.rb,
lib/datadog/ci/contrib/rspec/example.rb,
lib/datadog/ci/contrib/rspec/helpers.rb,
lib/datadog/ci/contrib/rspec/patcher.rb,
lib/datadog/ci/contrib/simplecov/ext.rb,
lib/datadog/ci/readonly_test_session.rb,
lib/datadog/ci/test_visibility/flush.rb,
lib/datadog/ci/transport/api/builder.rb,
lib/datadog/ci/configuration/settings.rb,
lib/datadog/ci/contrib/cuprite/driver.rb,
lib/datadog/ci/test_retries/component.rb,
lib/datadog/ci/transport/adapters/net.rb,
lib/datadog/ci/contrib/ciqueue/patcher.rb,
lib/datadog/ci/contrib/cucumber/filter.rb,
lib/datadog/ci/contrib/cuprite/patcher.rb,
lib/datadog/ci/contrib/instrumentation.rb,
lib/datadog/ci/contrib/knapsack/runner.rb,
lib/datadog/ci/contrib/lograge/patcher.rb,
lib/datadog/ci/contrib/minitest/runner.rb,
lib/datadog/ci/contrib/selenium/driver.rb,
lib/datadog/ci/remote/library_settings.rb,
lib/datadog/ci/test_visibility/context.rb,
lib/datadog/ci/transport/api/agentless.rb,
lib/datadog/ci/transport/api/evp_proxy.rb,
lib/datadog/ci/configuration/components.rb,
lib/datadog/ci/configuration/extensions.rb,
lib/datadog/ci/contrib/cucumber/patcher.rb,
lib/datadog/ci/contrib/knapsack/patcher.rb,
lib/datadog/ci/contrib/minitest/helpers.rb,
lib/datadog/ci/contrib/minitest/patcher.rb,
lib/datadog/ci/contrib/selenium/patcher.rb,
lib/datadog/ci/remote/slow_test_retries.rb,
lib/datadog/ci/test_discovery/component.rb,
lib/datadog/ci/test_retries/driver/base.rb,
lib/datadog/ci/contrib/activesupport/ext.rb,
lib/datadog/ci/contrib/minitest/reporter.rb,
lib/datadog/ci/contrib/minitest/runnable.rb,
lib/datadog/ci/contrib/rspec/integration.rb,
lib/datadog/ci/contrib/simplecov/patcher.rb,
lib/datadog/ci/ext/environment/extractor.rb,
lib/datadog/ci/ext/environment/providers.rb,
lib/datadog/ci/test_management/component.rb,
lib/datadog/ci/test_visibility/component.rb,
lib/datadog/ci/test_visibility/telemetry.rb,
lib/datadog/ci/test_visibility/transport.rb,
lib/datadog/ci/contrib/cucumber/formatter.rb,
lib/datadog/ci/contrib/knapsack/extension.rb,
lib/datadog/ci/contrib/parallel_tests/cli.rb,
lib/datadog/ci/contrib/parallel_tests/ext.rb,
lib/datadog/ci/test_retries/strategy/base.rb,
lib/datadog/ci/contrib/ciqueue/integration.rb,
lib/datadog/ci/contrib/cuprite/integration.rb,
lib/datadog/ci/contrib/lograge/integration.rb,
lib/datadog/ci/contrib/rspec/example_group.rb,
lib/datadog/ci/contrib/selenium/navigation.rb,
lib/datadog/ci/contrib/semantic_logger/ext.rb,
lib/datadog/ci/test_optimisation/component.rb,
lib/datadog/ci/test_optimisation/skippable.rb,
lib/datadog/ci/test_optimisation/telemetry.rb,
lib/datadog/ci/test_retries/null_component.rb,
lib/datadog/ci/test_visibility/known_tests.rb,
lib/datadog/ci/contrib/cucumber/integration.rb,
lib/datadog/ci/contrib/knapsack/integration.rb,
lib/datadog/ci/contrib/minitest/integration.rb,
lib/datadog/ci/contrib/selenium/integration.rb,
lib/datadog/ci/git/base_branch_sha_detector.rb,
lib/datadog/ci/test_retries/driver/no_retry.rb,
lib/datadog/ci/contrib/activesupport/patcher.rb,
lib/datadog/ci/contrib/simplecov/integration.rb,
lib/datadog/ci/test_visibility/store/process.rb,
lib/datadog/ci/contrib/lograge/log_subscriber.rb,
lib/datadog/ci/contrib/parallel_tests/patcher.rb,
lib/datadog/ci/contrib/semantic_logger/logger.rb,
lib/datadog/ci/ext/environment/providers/base.rb,
lib/datadog/ci/remote/library_settings_client.rb,
lib/datadog/ci/test_management/null_component.rb,
lib/datadog/ci/test_retries/strategy/no_retry.rb,
lib/datadog/ci/test_visibility/null_component.rb,
lib/datadog/ci/test_visibility/null_transport.rb,
lib/datadog/ci/test_visibility/total_coverage.rb,
lib/datadog/ci/contrib/cuprite/script_executor.rb,
lib/datadog/ci/contrib/semantic_logger/patcher.rb,
lib/datadog/ci/ext/environment/providers/azure.rb,
lib/datadog/ci/ext/environment/providers/buddy.rb,
lib/datadog/ci/ext/environment/providers/drone.rb,
lib/datadog/ci/contrib/cucumber/instrumentation.rb,
lib/datadog/ci/contrib/selenium/capybara_driver.rb,
lib/datadog/ci/ext/environment/providers/gitlab.rb,
lib/datadog/ci/ext/environment/providers/travis.rb,
lib/datadog/ci/test_management/tests_properties.rb,
lib/datadog/ci/test_optimisation/coverage/ddcov.rb,
lib/datadog/ci/test_optimisation/coverage/event.rb,
lib/datadog/ci/test_retries/driver/retry_failed.rb,
lib/datadog/ci/test_visibility/serializers/base.rb,
lib/datadog/ci/test_visibility/serializers/span.rb,
lib/datadog/ci/contrib/activesupport/integration.rb,
lib/datadog/ci/ext/environment/providers/bitrise.rb,
lib/datadog/ci/ext/environment/providers/jenkins.rb,
lib/datadog/ci/test_visibility/store/fiber_local.rb,
lib/datadog/ci/contrib/parallel_tests/integration.rb,
lib/datadog/ci/contrib/simplecov/result_extractor.rb,
lib/datadog/ci/ext/environment/providers/appveyor.rb,
lib/datadog/ci/ext/environment/providers/circleci.rb,
lib/datadog/ci/ext/environment/providers/teamcity.rb,
lib/datadog/ci/git/base_branch_sha_detection/base.rb,
lib/datadog/ci/impacted_tests_detection/component.rb,
lib/datadog/ci/test_retries/strategy/retry_failed.rb,
lib/datadog/ci/transport/adapters/net_http_client.rb,
lib/datadog/ci/transport/event_platform_transport.rb,
lib/datadog/ci/contrib/semantic_logger/integration.rb,
lib/datadog/ci/ext/environment/providers/bitbucket.rb,
lib/datadog/ci/ext/environment/providers/buildkite.rb,
lib/datadog/ci/ext/environment/providers/codefresh.rb,
lib/datadog/ci/ext/environment/providers/local_git.rb,
lib/datadog/ci/test_visibility/serializers/test_v1.rb,
lib/datadog/ci/test_visibility/serializers/test_v2.rb,
lib/datadog/ci/contrib/activesupport/logs_formatter.rb,
lib/datadog/ci/contrib/rspec/configuration/settings.rb,
lib/datadog/ci/test_optimisation/coverage/transport.rb,
lib/datadog/ci/contrib/rspec/documentation_formatter.rb,
lib/datadog/ci/git/base_branch_sha_detection/guesser.rb,
lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb,
lib/datadog/ci/cli/command/skippable_tests_percentage.rb,
lib/datadog/ci/contrib/cuprite/configuration/settings.rb,
lib/datadog/ci/contrib/lograge/configuration/settings.rb,
lib/datadog/ci/test_visibility/serializers/test_suite.rb,
lib/datadog/ci/contrib/cucumber/configuration/settings.rb,
lib/datadog/ci/contrib/minitest/configuration/settings.rb,
lib/datadog/ci/contrib/selenium/configuration/settings.rb,
lib/datadog/ci/test_retries/strategy/retry_flaky_fixed.rb,
lib/datadog/ci/test_visibility/serializers/test_module.rb,
lib/datadog/ci/contrib/simplecov/configuration/settings.rb,
lib/datadog/ci/ext/environment/providers/github_actions.rb,
lib/datadog/ci/test_visibility/serializers/test_session.rb,
lib/datadog/ci/test_retries/driver/retry_flake_detection.rb,
lib/datadog/ci/ext/environment/providers/aws_code_pipeline.rb,
lib/datadog/ci/ext/environment/providers/user_defined_tags.rb,
lib/datadog/ci/git/base_branch_sha_detection/branch_metric.rb,
lib/datadog/ci/test_optimisation/skippable_percentage/base.rb,
lib/datadog/ci/test_retries/strategy/retry_flake_detection.rb,
lib/datadog/ci/contrib/activesupport/configuration/settings.rb,
lib/datadog/ci/contrib/parallel_tests/configuration/settings.rb,
lib/datadog/ci/contrib/semantic_logger/configuration/settings.rb,
lib/datadog/ci/cli/command/skippable_tests_percentage_estimate.rb,
lib/datadog/ci/test_optimisation/skippable_percentage/estimator.rb,
lib/datadog/ci/test_visibility/serializers/factories/test_level.rb,
lib/datadog/ci/ext/environment/configuration_discrepancy_checker.rb,
lib/datadog/ci/test_optimisation/skippable_percentage/calculator.rb,
lib/datadog/ci/transport/adapters/telemetry_webmock_safe_adapter.rb,
lib/datadog/ci/git/base_branch_sha_detection/merge_base_extractor.rb,
lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb,
ext/datadog_ci_native/datadog_cov.c,
ext/datadog_ci_native/datadog_source_code.c
Overview
Datadog Test Optimization public API.
Defined Under Namespace
Modules: CLI, Codeowners, Configuration, Contrib, Ext, Git, ImpactedTestsDetection, Logs, Remote, TestDiscovery, TestManagement, TestOptimisation, TestRetries, TestVisibility, Transport, Utils, VERSION Classes: AsyncWriter, ConcurrentSpan, DummyWorker, ReadonlyTestModule, ReadonlyTestSession, ReservedTypeError, Span, Test, TestModule, TestSession, TestSuite, Worker
Class Method Summary collapse
-
.active_span ⇒ Datadog::CI::Span?
The active, unfinished custom (i.e. not test/suite/module/session) span.
-
.active_test ⇒ Datadog::CI::Test?
The active, unfinished test span.
-
.active_test_module ⇒ Datadog::CI::TestModule?
The active, unfinished test module.
-
.active_test_session ⇒ Datadog::CI::TestSession?
The active, unfinished test session.
-
.active_test_suite(test_suite_name = nil) ⇒ Datadog::CI::TestSuite?
The active, unfinished test suite.
-
.start_test(test_name, test_suite_name, service: nil, tags: {}) ⇒ Datadog::CI::Test?
Same as CI.trace_test but it does not accept a block.
-
.start_test_module(test_module_name, service: nil, tags: {}) ⇒ Datadog::CI::TestModule?
Starts a ci_test_module that represents a single test module (for most Ruby test frameworks module will correspond 1-1 to the test session).
-
.start_test_session(service: Utils::Configuration.fetch_service_name("test"), tags: {}, total_tests_count: 0) ⇒ Datadog::CI::TestSession?
Starts a ci_test_session that represents the whole test session run.
-
.start_test_suite(test_suite_name, service: nil, tags: {}) ⇒ Datadog::CI::TestSuite?
Starts a ci_test_suite that represents a single test suite.
-
.trace(span_name, type: "span", tags: {}) {|ci_span, ci_span| ... } ⇒ Object, ...
Trace any custom span inside a test.
-
.trace_test(test_name, test_suite_name, service: nil, tags: {}) {|ci_test, if| ... } ⇒ Object, ...
Return a ci_test that will trace a test called ‘test_name`.
Class Method Details
.active_span ⇒ Datadog::CI::Span?
The active, unfinished custom (i.e. not test/suite/module/session) span. If no span is active, or if the active span is not a custom span, returns nil.
The active span belongs to an active_test.
Usage:
“‘ # start span Datadog::CI.trace(
"Given I have 42 cucumbers",
type: "step",
tags: {}
)
# somewhere else, access the active step span step_span = Datadog::CI.active_span step_span.finish() “‘
373 374 375 376 |
# File 'lib/datadog/ci.rb', line 373 def active_span span = test_visibility.active_span span if span && !Ext::AppTypes::CI_SPAN_TYPES.include?(span.type) end |
.active_test ⇒ Datadog::CI::Test?
The active, unfinished test span.
Usage:
“‘ # start a test Datadog::CI.start_test(
"test_add_two_numbers",
"calculator_tests",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
)
# somewhere else, access the active test test_span = Datadog::CI.active_test test_span.passed! test_span.finish “‘
399 400 401 |
# File 'lib/datadog/ci.rb', line 399 def active_test test_visibility.active_test end |
.active_test_module ⇒ Datadog::CI::TestModule?
The active, unfinished test module.
Usage:
“‘ # start a test module Datadog::CI.start_test_module(
"my-module",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
)
# somewhere else, access the current module test_module = Datadog::CI.active_test_module test_module.finish “‘
134 135 136 |
# File 'lib/datadog/ci.rb', line 134 def active_test_module test_visibility.active_test_module end |
.active_test_session ⇒ Datadog::CI::TestSession?
The active, unfinished test session.
Usage:
“‘ # start a test session Datadog::CI.start_test_session(
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
)
# somewhere else, access the session test_session = Datadog::CI.active_test_session test_session.finish “‘
73 74 75 |
# File 'lib/datadog/ci.rb', line 73 def active_test_session test_visibility.active_test_session end |
.active_test_suite(test_suite_name = nil) ⇒ Datadog::CI::TestSuite?
The active, unfinished test suite.
Usage:
“‘ # start a test suite Datadog::CI.start_test_suite(
"calculator_tests",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
)
# Somewhere else after the suite has ended test_suite = Datadog::CI.active_test_suite(“calculator_tests”) test_suite.finish “‘
Most of the time, there is only one active test suite - except when using minitest with parallel test runner, such as rails built-in test runner.
When using RSpec or minitest without parallel test runner, there is only one active test suite, so you can use the following code to fetch it:
“‘ test_suite = Datadog::CI.active_test_suite test_suite.finish “`
204 205 206 |
# File 'lib/datadog/ci.rb', line 204 def active_test_suite(test_suite_name = nil) test_visibility.active_test_suite(test_suite_name) end |
.start_test(test_name, test_suite_name, service: nil, tags: {}) ⇒ Datadog::CI::Test?
Same as trace_test but it does not accept a block. Raises an error if a test is already active.
Usage:
“‘ ci_test = Datadog::CI.start_test(
"test_add_two_numbers",
"calculator_tests",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
) # … run test here … ci_test.finish “‘
290 291 292 293 294 295 296 297 |
# File 'lib/datadog/ci.rb', line 290 def start_test(test_name, test_suite_name, service: nil, tags: {}) Utils::Telemetry.inc( Ext::Telemetry::METRIC_MANUAL_API_EVENTS, 1, {Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::TEST} ) test_visibility.trace_test(test_name, test_suite_name, service: service, tags: ) end |
.start_test_module(test_module_name, service: nil, tags: {}) ⇒ Datadog::CI::TestModule?
Starts a ci_test_module that represents a single test module (for most Ruby test frameworks module will correspond 1-1 to the test session).
Read Datadog documentation on test modules [here](docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#module).
Returns the existing test session if one is already active. There is at most a single test module per process active at any given time.
The start_test_module method is used to mark the start of the test session: “‘ Datadog::CI.start_test_module(
"my-module",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
)
# Somewhere else after the module has ended Datadog::CI.active_test_module.finish “‘
Remember that calling Datadog::CI::TestModule#finish is mandatory.
105 106 107 108 109 110 111 112 113 |
# File 'lib/datadog/ci.rb', line 105 def start_test_module(test_module_name, service: nil, tags: {}) Utils::Telemetry.inc( Ext::Telemetry::METRIC_MANUAL_API_EVENTS, 1, {Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::MODULE} ) test_visibility.start_test_module(test_module_name, service: service, tags: ) end |
.start_test_session(service: Utils::Configuration.fetch_service_name("test"), tags: {}, total_tests_count: 0) ⇒ Datadog::CI::TestSession?
Starts a ci_test_session that represents the whole test session run.
Read Datadog documentation on test sessions [here](docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions).
Returns the existing test session if one is already active. There is at most a single test session per process.
The start_test_session method is used to mark the start of the test session: “‘ Datadog::CI.start_test_session(
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" },
total_tests_count: 100
)
# Somewhere else after test run has ended Datadog::CI.active_test_session.finish “‘
Remember that calling Datadog::CI::TestSession#finish is mandatory.
46 47 48 49 50 51 52 53 |
# File 'lib/datadog/ci.rb', line 46 def start_test_session(service: Utils::Configuration.fetch_service_name("test"), tags: {}, total_tests_count: 0) Utils::Telemetry.inc( Ext::Telemetry::METRIC_MANUAL_API_EVENTS, 1, {Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::SESSION} ) test_visibility.start_test_session(service: service, tags: , estimated_total_tests_count: total_tests_count) end |
.start_test_suite(test_suite_name, service: nil, tags: {}) ⇒ Datadog::CI::TestSuite?
Starts a ci_test_suite that represents a single test suite. If a test suite with given name is running, returns the existing test suite.
Read Datadog documentation on test suites [here](docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#module).
The start_test_suite method is used to mark the start of a test suite: “‘ Datadog::CI.start_test_suite(
"calculator_tests",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
)
# Somewhere else after the suite has ended Datadog::CI.active_test_suite(“calculator_tests”).finish “‘
Remember that calling Datadog::CI::TestSuite#finish is mandatory.
163 164 165 166 167 168 169 170 171 |
# File 'lib/datadog/ci.rb', line 163 def start_test_suite(test_suite_name, service: nil, tags: {}) Utils::Telemetry.inc( Ext::Telemetry::METRIC_MANUAL_API_EVENTS, 1, {Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::SUITE} ) test_visibility.start_test_suite(test_suite_name, service: service, tags: ) end |
.trace(span_name, type: "span", tags: {}) {|ci_span, ci_span| ... } ⇒ Object, ...
Trace any custom span inside a test. For example, you could trace:
-
cucumber step
-
database query
-
any custom operation you want to see in your trace view
You can use this method with a do-block
like:
“‘ Datadog::CI.trace(
"Given I have 42 cucumbers",
type: "step",
tags: {}
) do
run_operation
end “‘
The trace method can also be used without a block in this way: “‘ ci_span = Datadog::CI.trace(
"Given I have 42 cucumbers",
type: "step",
tags: {}
) # … run test here … ci_span.finish “‘ Remember that in this case, calling Datadog::CI::Span#finish is mandatory.
339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/datadog/ci.rb', line 339 def trace(span_name, type: "span", tags: {}, &block) if Ext::AppTypes::CI_SPAN_TYPES.include?(type) raise( ReservedTypeError, "Span type #{type} is reserved for Datadog Test Optimization. " \ "Reserved types are: #{Ext::AppTypes::CI_SPAN_TYPES}" ) end test_visibility.trace(span_name, type: type, tags: , &block) end |
.trace_test(test_name, test_suite_name, service: nil, tags: {}) {|ci_test, if| ... } ⇒ Object, ...
Return a ci_test that will trace a test called ‘test_name`. Raises an error if a test is already active. If there is an active test session, the new test will be connected to the session. The test will inherit service name and tags from the running test session if not provided in parameters.
You could trace your test using a do-block
like:
“‘ Datadog::CI.trace_test(
"test_add_two_numbers",
"calculator_tests",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
) do |ci_test|
result = run_test
if result.ok?
ci_test.passed!
else
ci_test.failed!(exception: result.exception)
end
end “‘
The trace_test method can also be used without a block in this way: “‘ ci_test = Datadog::CI.trace_test(
"test_add_two_numbers",
"calculator_tests",
service: "my-web-site-tests",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
) # … run test here … ci_test.finish “‘
Remember that in this case, calling Datadog::CI::Test#finish is mandatory.
258 259 260 261 262 263 264 265 266 |
# File 'lib/datadog/ci.rb', line 258 def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) Utils::Telemetry.inc( Ext::Telemetry::METRIC_MANUAL_API_EVENTS, 1, {Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::TEST} ) test_visibility.trace_test(test_name, test_suite_name, service: service, tags: , &block) end |