Class: Datadog::CI::Span
- Inherits:
-
Object
- Object
- Datadog::CI::Span
- Defined in:
- lib/datadog/ci/span.rb
Overview
Represents a single part of a test run. Could be a session, suite, test, or any custom span.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#tracer_span ⇒ Object
readonly
Returns the value of attribute tracer_span.
Instance Method Summary collapse
-
#failed!(exception: nil) ⇒ void
Sets the status of the span to “fail”.
-
#finish ⇒ void
Finishes the span.
-
#get_tag(key) ⇒ String
Gets tag value by key.
-
#id ⇒ Integer
The ID of the span.
-
#initialize(tracer_span) ⇒ Span
constructor
A new instance of Span.
-
#name ⇒ String
The name of the span.
-
#passed! ⇒ void
Sets the status of the span to “pass”.
-
#service ⇒ String
The service name of the span.
- #set_default_tags ⇒ Object
- #set_environment_runtime_tags ⇒ Object
-
#set_metric(key, value) ⇒ void
Sets metric value by key.
-
#set_tag(key, value) ⇒ void
Sets tag value by key.
-
#set_tags(tags) ⇒ void
Sets multiple tags at once.
-
#skipped!(exception: nil, reason: nil) ⇒ void
Sets the status of the span to “skip”.
-
#span_type ⇒ String
The type of the span (for example “test” or type that was provided to [Datadog::CI.trace]).
- #to_s ⇒ Object
Constructor Details
#initialize(tracer_span) ⇒ Span
Returns a new instance of Span.
15 16 17 |
# File 'lib/datadog/ci/span.rb', line 15 def initialize(tracer_span) @tracer_span = tracer_span end |
Instance Attribute Details
#tracer_span ⇒ Object (readonly)
Returns the value of attribute tracer_span.
13 14 15 |
# File 'lib/datadog/ci/span.rb', line 13 def tracer_span @tracer_span end |
Instance Method Details
#failed!(exception: nil) ⇒ void
This method returns an undefined value.
Sets the status of the span to “fail”.
48 49 50 51 52 |
# File 'lib/datadog/ci/span.rb', line 48 def failed!(exception: nil) tracer_span.status = 1 tracer_span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::FAIL) tracer_span.set_error(exception) unless exception.nil? end |
#finish ⇒ void
This method returns an undefined value.
Finishes the span.
89 90 91 |
# File 'lib/datadog/ci/span.rb', line 89 def finish tracer_span.finish end |
#get_tag(key) ⇒ String
Gets tag value by key.
67 68 69 |
# File 'lib/datadog/ci/span.rb', line 67 def get_tag(key) tracer_span.get_tag(key) end |
#id ⇒ Integer
Returns the ID of the span.
20 21 22 |
# File 'lib/datadog/ci/span.rb', line 20 def id tracer_span.id end |
#name ⇒ String
Returns the name of the span.
25 26 27 |
# File 'lib/datadog/ci/span.rb', line 25 def name tracer_span.name end |
#passed! ⇒ void
This method returns an undefined value.
Sets the status of the span to “pass”.
41 42 43 |
# File 'lib/datadog/ci/span.rb', line 41 def passed! tracer_span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::PASS) end |
#service ⇒ String
Returns the service name of the span.
30 31 32 |
# File 'lib/datadog/ci/span.rb', line 30 def service tracer_span.service end |
#set_default_tags ⇒ Object
108 109 110 |
# File 'lib/datadog/ci/span.rb', line 108 def tracer_span.set_tag(Ext::Test::TAG_SPAN_KIND, Ext::AppTypes::TYPE_TEST) end |
#set_environment_runtime_tags ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/datadog/ci/span.rb', line 100 def tracer_span.set_tag(Ext::Test::TAG_OS_ARCHITECTURE, ::RbConfig::CONFIG["host_cpu"]) tracer_span.set_tag(Ext::Test::TAG_OS_PLATFORM, ::RbConfig::CONFIG["host_os"]) tracer_span.set_tag(Ext::Test::TAG_RUNTIME_NAME, Core::Environment::Ext::LANG_ENGINE) tracer_span.set_tag(Ext::Test::TAG_RUNTIME_VERSION, Core::Environment::Ext::ENGINE_VERSION) tracer_span.set_tag(Ext::Test::TAG_COMMAND, Utils::TestRun.command) end |
#set_metric(key, value) ⇒ void
This method returns an undefined value.
Sets metric value by key.
83 84 85 |
# File 'lib/datadog/ci/span.rb', line 83 def set_metric(key, value) tracer_span.set_metric(key, value) end |
#set_tag(key, value) ⇒ void
This method returns an undefined value.
Sets tag value by key.
75 76 77 |
# File 'lib/datadog/ci/span.rb', line 75 def set_tag(key, value) tracer_span.set_tag(key, value) end |
#set_tags(tags) ⇒ void
This method returns an undefined value.
Sets multiple tags at once.
96 97 98 |
# File 'lib/datadog/ci/span.rb', line 96 def () tracer_span.() end |
#skipped!(exception: nil, reason: nil) ⇒ void
This method returns an undefined value.
Sets the status of the span to “skip”.
58 59 60 61 62 |
# File 'lib/datadog/ci/span.rb', line 58 def skipped!(exception: nil, reason: nil) tracer_span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::SKIP) tracer_span.set_error(exception) unless exception.nil? tracer_span.set_tag(Ext::Test::TAG_SKIP_REASON, reason) unless reason.nil? end |
#span_type ⇒ String
Returns the type of the span (for example “test” or type that was provided to [Datadog::CI.trace]).
35 36 37 |
# File 'lib/datadog/ci/span.rb', line 35 def span_type tracer_span.type end |
#to_s ⇒ Object
112 113 114 |
# File 'lib/datadog/ci/span.rb', line 112 def to_s "#{self.class}(name:#{name},tracer_span:#{@tracer_span})" end |