Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datadog::CI.trace_test always starts a new trace #74

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/datadog/ci/recorder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "datadog/tracing"
require "datadog/tracing/trace_digest"

require "rbconfig"

Expand Down Expand Up @@ -62,7 +63,9 @@ def trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &
span_options = {
resource: test_name,
service: service_name,
span_type: Ext::AppTypes::TYPE_TEST
span_type: Ext::AppTypes::TYPE_TEST,
# this option is needed to force a new trace to be created
continue_from: Datadog::Tracing::TraceDigest.new
}

tags[Ext::Test::TAG_NAME] = test_name
Expand Down Expand Up @@ -120,7 +123,7 @@ def active_test_session
@global_context.active_test_session
end

# TODO: does it make sense to have a paramter here?
# TODO: does it make sense to have a parameter here?
def deactivate_test(test)
@local_context.deactivate_test!(test)
end
Expand Down
19 changes: 2 additions & 17 deletions lib/datadog/ci/test_visibility/serializers/test_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,11 @@ module CI
module TestVisibility
module Serializers
class TestV2 < TestV1
CONTENT_FIELDS = [
"trace_id", "span_id",
"name", "resource", "service",
"error", "start", "duration",
"meta", "metrics", "test_session_id",
"type" => "span_type"
].freeze
CONTENT_FIELDS = (["test_session_id"] + TestV1::CONTENT_FIELDS).freeze

CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS)

REQUIRED_FIELDS = [
"test_session_id",
"trace_id",
"span_id",
"error",
"name",
"resource",
"start",
"duration"
].freeze
REQUIRED_FIELDS = (["test_session_id"] + TestV1::REQUIRED_FIELDS).freeze

def content_fields
CONTENT_FIELDS
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/test_visibility/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def encode_traces(traces)
if spans.respond_to?(:filter_map)
spans.filter_map { |span| encode_span(trace, span) }
else
trace.spans.map { |span| encode_span(trace, span) }.reject(&:nil?)
spans.map { |span| encode_span(trace, span) }.reject(&:nil?)
end
end
end
Expand Down
Loading