Module: Datadog::CI
- Defined in:
- lib/datadog/ci.rb,
lib/datadog/ci/span.rb,
lib/datadog/ci/test.rb,
lib/datadog/ci/ext/git.rb,
lib/datadog/ci/version.rb,
lib/datadog/ci/ext/test.rb,
lib/datadog/ci/recorder.rb,
lib/datadog/ci/utils/git.rb,
lib/datadog/ci/utils/url.rb,
lib/datadog/ci/extensions.rb,
lib/datadog/ci/ext/settings.rb,
lib/datadog/ci/context/local.rb,
lib/datadog/ci/ext/app_types.rb,
lib/datadog/ci/ext/transport.rb,
lib/datadog/ci/transport/gzip.rb,
lib/datadog/ci/transport/http.rb,
lib/datadog/ci/ext/environment.rb,
lib/datadog/ci/contrib/settings.rb,
lib/datadog/ci/contrib/rspec/ext.rb,
lib/datadog/ci/transport/api/base.rb,
lib/datadog/ci/contrib/integration.rb,
lib/datadog/ci/contrib/cucumber/ext.rb,
lib/datadog/ci/contrib/minitest/ext.rb,
lib/datadog/ci/contrib/rspec/example.rb,
lib/datadog/ci/contrib/rspec/patcher.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/minitest/hooks.rb,
lib/datadog/ci/transport/api/evp_proxy.rb,
lib/datadog/ci/configuration/components.rb,
lib/datadog/ci/contrib/cucumber/patcher.rb,
lib/datadog/ci/contrib/minitest/patcher.rb,
lib/datadog/ci/contrib/rspec/integration.rb,
lib/datadog/ci/ext/environment/extractor.rb,
lib/datadog/ci/ext/environment/providers.rb,
lib/datadog/ci/test_visibility/transport.rb,
lib/datadog/ci/contrib/cucumber/formatter.rb,
lib/datadog/ci/transport/api/ci_test_cycle.rb,
lib/datadog/ci/contrib/cucumber/integration.rb,
lib/datadog/ci/contrib/minitest/integration.rb,
lib/datadog/ci/ext/environment/providers/base.rb,
lib/datadog/ci/ext/environment/providers/azure.rb,
lib/datadog/ci/ext/environment/providers/buddy.rb,
lib/datadog/ci/contrib/cucumber/instrumentation.rb,
lib/datadog/ci/ext/environment/providers/gitlab.rb,
lib/datadog/ci/ext/environment/providers/travis.rb,
lib/datadog/ci/test_visibility/serializers/base.rb,
lib/datadog/ci/test_visibility/serializers/span.rb,
lib/datadog/ci/ext/environment/providers/bitrise.rb,
lib/datadog/ci/ext/environment/providers/jenkins.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/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/contrib/rspec/configuration/settings.rb,
lib/datadog/ci/contrib/cucumber/configuration/settings.rb,
lib/datadog/ci/contrib/minitest/configuration/settings.rb,
lib/datadog/ci/ext/environment/providers/github_actions.rb,
lib/datadog/ci/ext/environment/providers/aws_code_pipeline.rb,
lib/datadog/ci/ext/environment/providers/user_defined_tags.rb,
lib/datadog/ci/test_visibility/serializers/factories/test_level.rb
Overview
Datadog CI visibility public API.
Defined Under Namespace
Modules: Configuration, Context, Contrib, Ext, Extensions, TestVisibility, Transport, Utils, VERSION Classes: Recorder, Span, Test
Class Method Summary collapse
-
.active_span(span_type) ⇒ Datadog::CI::Span?
The active, unfinished custom span if it matches given type.
-
.active_test ⇒ Datadog::CI::Test?
The active, unfinished test span.
-
.deactivate_test(test) ⇒ Object
Internal only, to finish a test use Datadog::CI::Test#finish.
-
.start_test(test_name, service_name: nil, operation_name: "test", tags: {}) ⇒ Datadog::CI::Test
Same as #trace_test but it does not accept a block.
-
.trace(span_type, span_name, tags: {}) {|ci_span| ... } ⇒ Object, Datadog::CI::Span
Trace any custom span inside a test.
-
.trace_test(test_name, service_name: nil, operation_name: "test", tags: {}) {|ci_test| ... } ⇒ Object, Datadog::CI::Test
Return a ci_test that will trace a test called ‘test_name`.
Class Method Details
.active_span(span_type) ⇒ Datadog::CI::Span?
The active, unfinished custom span if it matches given type. If no span is active, or if the active span is not a custom span with given type, returns nil.
The active span belongs to an active_test.
Usage:
“‘ # start span Datadog::CI.trace(
"step",
"Given I have 42 cucumbers",
tags: {}
)
# somewhere else, access the active “step” span step_span = Datadog::CI.active_span(“step”) step_span.finish() “‘
157 158 159 160 |
# File 'lib/datadog/ci.rb', line 157 def active_span(span_type) span = recorder.active_span span if span && span.span_type == 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',
service: "my-web-site-tests",
operation_name: "test",
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 “‘
183 184 185 |
# File 'lib/datadog/ci.rb', line 183 def active_test recorder.active_test end |
.deactivate_test(test) ⇒ Object
Internal only, to finish a test use Datadog::CI::Test#finish
188 189 190 |
# File 'lib/datadog/ci.rb', line 188 def deactivate_test(test) recorder.deactivate_test(test) end |
.start_test(test_name, service_name: nil, operation_name: "test", 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',
service: "my-web-site-tests",
operation_name: "test",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
) run_test ci_test.finish “‘
87 88 89 |
# File 'lib/datadog/ci.rb', line 87 def start_test(test_name, service_name: nil, operation_name: "test", tags: {}) recorder.trace_test(test_name, service_name: service_name, operation_name: operation_name, tags: ) end |
.trace(span_type, span_name, tags: {}) {|ci_span| ... } ⇒ Object, Datadog::CI::Span
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 thi method with a do-block like:
“‘ Datadog::CI.trace(
"step",
"Given I have 42 cucumbers",
tags: {}
) do
run_operation
end “‘
The #trace method can also be used without a block in this way: “‘ ci_span = Datadog::CI.trace(
"step",
"Given I have 42 cucumbers",
tags: {}
) run_test ci_span.finish “‘ Remember that in this case, calling Datadog::CI::Span#finish is mandatory.
130 131 132 |
# File 'lib/datadog/ci.rb', line 130 def trace(span_type, span_name, tags: {}, &block) recorder.trace(span_type, span_name, tags: , &block) end |
.trace_test(test_name, service_name: nil, operation_name: "test", tags: {}) {|ci_test| ... } ⇒ Object, Datadog::CI::Test
Return a ci_test that will trace a test called ‘test_name`. Raises an error if a test is already active.
You could trace your test using a do-block like:
“‘ Datadog::CI.trace_test(
"test_add_two_numbers",
service_name: "my-web-site-tests",
operation_name: "test",
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',
service: "my-web-site-tests",
operation_name: "test",
tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
) run_test ci_test.finish “‘
Remember that in this case, calling Datadog::CI::Test#finish is mandatory.
60 61 62 |
# File 'lib/datadog/ci.rb', line 60 def trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &block) recorder.trace_test(test_name, service_name: service_name, operation_name: operation_name, tags: , &block) end |