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!(span, tags = {}) ⇒ Object
Adds tags to a CI test span.
- .skipped!(span, exception = nil) ⇒ Object
-
.trace(tracer, 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!(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.(span, = {}) ||= {} # Set default tags span.context.origin = Ext::Test::CONTEXT_ORIGIN if span.context Datadog::Contrib::Analytics.set_measured(span) span.set_tag(Ext::Test::TAG_SPAN_KIND, Ext::AppTypes::TEST) # Set environment tags @environment_tags ||= Ext::Environment.(ENV) @environment_tags.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(tracer, span_name, options = {}) ⇒ Object
Creates a new span for a CI test
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/datadog/ci/test.rb', line 16 def self.trace(tracer, span_name, = {}) = { span_type: Ext::AppTypes::TEST }.merge([:span_options] || {}) if block_given? tracer.trace(span_name, ) do |span| (span, ) yield(span) end else span = tracer.trace(span_name, ) (span, ) span end end |