Skip to content

Commit

Permalink
move CI.trace logic to Recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Nov 1, 2023
1 parent 48f976b commit bbe95ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/datadog/ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,8 @@ def trace_test(test_name, service_name: nil, operation_name: nil, tags: {})
end
end

def trace(span_type, span_name, span_options = {})
span_options[:resource] = span_name
span_options[:span_type] = span_type

if block_given?
::Datadog::Tracing.trace(span_name, **span_options) do |tracer_span|
yield Span.new(tracer_span)
end
else
tracer_span = Datadog::Tracing.trace(span_name, **span_options)
Span.new(tracer_span)
end
def trace(span_type, span_name, &block)
Recorder.trace(span_type, span_name, &block)
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions lib/datadog/ci/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ def self.trace_test(test_name, service_name: nil, operation_name: nil, tags: {})
end
end

def self.trace(span_type, span_name)
span_options = {
resource: span_name,
span_type: span_type
}

if block_given?
::Datadog::Tracing.trace(span_name, **span_options) do |tracer_span|
yield Span.new(tracer_span)
end
else
tracer_span = Datadog::Tracing.trace(span_name, **span_options)
Span.new(tracer_span)
end
end

# Adds tags to a CI test span.
def self.set_tags!(trace, span, tags = {})
tags ||= {}
Expand Down

0 comments on commit bbe95ff

Please sign in to comment.