Module: Datadog::CI::Test
- Defined in:
- lib/datadog/ci/test.rb
Overview
Common behavior for CI tests
Class Method Summary collapse
- .failed!(span, exception = nil) ⇒ Object
- .passed!(span) ⇒ Object
-
.set_tags!(trace, span, tags = {}) ⇒ Object
Adds tags to a CI test span.
- .skipped!(span, exception = nil) ⇒ Object
-
.trace(span_name, options = {}) ⇒ Object
Creates a new span for a CI test.
Class Method Details
.failed!(span, exception = nil) ⇒ Object
62 63 64 65 66 |
# File 'lib/datadog/ci/test.rb', line 62 def self.failed!(span, exception = nil) span.status = 1 span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::FAIL) span.set_error(exception) unless exception.nil? end |
.passed!(span) ⇒ Object
58 59 60 |
# File 'lib/datadog/ci/test.rb', line 58 def self.passed!(span) span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::PASS) end |
.set_tags!(trace, span, tags = {}) ⇒ Object
Adds tags to a CI test span.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/datadog/ci/test.rb', line 34 def self.(trace, span, = {}) ||= {} # Set default tags trace.origin = Ext::Test::CONTEXT_ORIGIN if trace Datadog::Tracing::Contrib::Analytics.set_measured(span) span.set_tag(Ext::Test::TAG_SPAN_KIND, Ext::AppTypes::TYPE_TEST) # Set environment tags ||= Ext::Environment.(ENV) .each { |k, v| span.set_tag(k, v) } # Set contextual tags span.set_tag(Ext::Test::TAG_FRAMEWORK, [:framework]) if [:framework] span.set_tag(Ext::Test::TAG_FRAMEWORK_VERSION, [:framework_version]) if [:framework_version] span.set_tag(Ext::Test::TAG_NAME, [:test_name]) if [:test_name] span.set_tag(Ext::Test::TAG_SUITE, [:test_suite]) if [:test_suite] span.set_tag(Ext::Test::TAG_TYPE, [:test_type]) if [:test_type] (span) span end |
.skipped!(span, exception = nil) ⇒ Object
68 69 70 71 |
# File 'lib/datadog/ci/test.rb', line 68 def self.skipped!(span, exception = nil) span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::SKIP) span.set_error(exception) unless exception.nil? end |
.trace(span_name, options = {}) ⇒ Object
Creates a new span for a CI test
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/datadog/ci/test.rb', line 15 def self.trace(span_name, = {}) = { span_type: Ext::AppTypes::TYPE_TEST }.merge([:span_options] || {}) if block_given? Tracing.trace(span_name, **) do |span, trace| (trace, span, ) yield(span, trace) end else span = Tracing.trace(span_name, **) trace = Tracing.active_trace (trace, span, ) span end end |