Class: Datadog::CI::Recorder
- Inherits:
-
Object
- Object
- Datadog::CI::Recorder
- Defined in:
- lib/datadog/ci/recorder.rb
Overview
Common behavior for CI tests
Instance Attribute Summary collapse
-
#environment_tags ⇒ Object
readonly
Returns the value of attribute environment_tags.
Instance Method Summary collapse
- #active_span ⇒ Object
- #active_test ⇒ Object
- #deactivate_test(test) ⇒ Object
-
#initialize ⇒ Recorder
constructor
A new instance of Recorder.
- #trace(span_type, span_name, tags: {}, &block) ⇒ Object
-
#trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &block) ⇒ Object
Creates a new span for a CI test.
Constructor Details
Instance Attribute Details
#environment_tags ⇒ Object (readonly)
Returns the value of attribute environment_tags.
20 21 22 |
# File 'lib/datadog/ci/recorder.rb', line 20 def @environment_tags end |
Instance Method Details
#active_span ⇒ Object
84 85 86 87 |
# File 'lib/datadog/ci/recorder.rb', line 84 def active_span tracer_span = Datadog::Tracing.active_span Span.new(tracer_span) if tracer_span end |
#active_test ⇒ Object
76 77 78 |
# File 'lib/datadog/ci/recorder.rb', line 76 def active_test @local_context.active_test end |
#deactivate_test(test) ⇒ Object
80 81 82 |
# File 'lib/datadog/ci/recorder.rb', line 80 def deactivate_test(test) @local_context.deactivate_test!(test) end |
#trace(span_type, span_name, tags: {}, &block) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/datadog/ci/recorder.rb', line 59 def trace(span_type, span_name, tags: {}, &block) = { resource: span_name, span_type: span_type } if block Datadog::Tracing.trace(span_name, **) do |tracer_span, trace| block.call(build_span(tracer_span, )) end else tracer_span = Datadog::Tracing.trace(span_name, **) build_span(tracer_span, ) end end |
#trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &block) ⇒ Object
Creates a new span for a CI test
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datadog/ci/recorder.rb', line 28 def trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &block) = { resource: test_name, service: service_name, span_type: Ext::AppTypes::TYPE_TEST } [Ext::Test::TAG_NAME] = test_name if block Datadog::Tracing.trace(operation_name, **) do |tracer_span, trace| set_trace_origin(trace) test = build_test(tracer_span, ) @local_context.activate_test!(test) do block.call(test) end end else tracer_span = Datadog::Tracing.trace(operation_name, **) trace = Datadog::Tracing.active_trace set_trace_origin(trace) test = build_test(tracer_span, ) @local_context.activate_test!(test) test end end |