Skip to content

Commit 94f84ec

Browse files
refactor: split collect_chunks into two methods (#1021)
# What does this PR do? This refactor splits the logic in `collect_trace_chunks` between the trace exporter spans (v04 and v05) and the mini agent spans (pb::Spans). it completely removes usage of the `TraceCollection` struct from data-pipeline, and instead introduces the `TraceChunks` enum to differentiate between v04 and v05. Currently the way the code is structured makes replacing ByteString with the slice harder due to shared lifetime. Furthermore, the enums encodes two different codepaths, the spanBytes and span pb which never interact with each other. So having function that handle both span bytes and pb spans is pure complexity overhead. This refactor also removes a bunch of panics and lines of code that were here because to handle the "fake" pb spans and trace exporter spans overlap, which is practice never happens. Lastly, this remove the TracerParams struct. Every occurence of if was creating it, and invoking `TryInto<TracerCollection>` just after on it. So replacing it by a simple function is a lot less complex for the same feature set. # Motivation Prepare for using `SpanSlice<'a>` instead of `SpanBytes` in the trace exporter.
1 parent db2fe68 commit 94f84ec

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/trace_processor.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use datadog_trace_obfuscation::obfuscate::obfuscate_span;
1313
use datadog_trace_protobuf::pb;
1414
use datadog_trace_utils::trace_utils::{self};
1515
use datadog_trace_utils::trace_utils::{EnvironmentType, SendData};
16-
use datadog_trace_utils::tracer_payload::{TraceChunkProcessor, TraceCollection};
16+
use datadog_trace_utils::tracer_payload::TraceChunkProcessor;
1717

1818
use crate::{
1919
config::Config,
@@ -96,15 +96,14 @@ impl TraceProcessor for ServerlessTraceProcessor {
9696
}
9797
};
9898

99-
let payload = match trace_utils::collect_trace_chunks(
100-
TraceCollection::V07(traces),
99+
let payload = match trace_utils::collect_pb_trace_chunks(
100+
traces,
101101
&tracer_header_tags,
102102
&mut ChunkProcessor {
103103
config: config.clone(),
104104
mini_agent_metadata: mini_agent_metadata.clone(),
105105
},
106106
true, // In mini agent, we always send agentless
107-
false,
108107
) {
109108
Ok(res) => res,
110109
Err(err) => {

0 commit comments

Comments
 (0)