Skip to content

Commit a5dd26f

Browse files
authored
Merge pull request #74 from DataDog/anmarchenko/single_trace_per_test
Datadog::CI.trace_test always starts a new trace
2 parents 8d8cead + a14f853 commit a5dd26f

File tree

15 files changed

+439
-376
lines changed

15 files changed

+439
-376
lines changed

lib/datadog/ci/recorder.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "datadog/tracing"
4+
require "datadog/tracing/trace_digest"
45

56
require "rbconfig"
67

@@ -62,7 +63,9 @@ def trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &
6263
span_options = {
6364
resource: test_name,
6465
service: service_name,
65-
span_type: Ext::AppTypes::TYPE_TEST
66+
span_type: Ext::AppTypes::TYPE_TEST,
67+
# this option is needed to force a new trace to be created
68+
continue_from: Datadog::Tracing::TraceDigest.new
6669
}
6770

6871
tags[Ext::Test::TAG_NAME] = test_name
@@ -120,7 +123,7 @@ def active_test_session
120123
@global_context.active_test_session
121124
end
122125

123-
# TODO: does it make sense to have a paramter here?
126+
# TODO: does it make sense to have a parameter here?
124127
def deactivate_test(test)
125128
@local_context.deactivate_test!(test)
126129
end

lib/datadog/ci/test_visibility/serializers/test_v2.rb

+2-17
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,11 @@ module CI
88
module TestVisibility
99
module Serializers
1010
class TestV2 < TestV1
11-
CONTENT_FIELDS = [
12-
"trace_id", "span_id",
13-
"name", "resource", "service",
14-
"error", "start", "duration",
15-
"meta", "metrics", "test_session_id",
16-
"type" => "span_type"
17-
].freeze
11+
CONTENT_FIELDS = (["test_session_id"] + TestV1::CONTENT_FIELDS).freeze
1812

1913
CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS)
2014

21-
REQUIRED_FIELDS = [
22-
"test_session_id",
23-
"trace_id",
24-
"span_id",
25-
"error",
26-
"name",
27-
"resource",
28-
"start",
29-
"duration"
30-
].freeze
15+
REQUIRED_FIELDS = (["test_session_id"] + TestV1::REQUIRED_FIELDS).freeze
3116

3217
def content_fields
3318
CONTENT_FIELDS

lib/datadog/ci/test_visibility/transport.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def encode_traces(traces)
8181
if spans.respond_to?(:filter_map)
8282
spans.filter_map { |span| encode_span(trace, span) }
8383
else
84-
trace.spans.map { |span| encode_span(trace, span) }.reject(&:nil?)
84+
spans.map { |span| encode_span(trace, span) }.reject(&:nil?)
8585
end
8686
end
8787
end

0 commit comments

Comments
 (0)