Skip to content

Commit baf4f6f

Browse files
committed
fix(traces): suppress clippy cast_possible_truncation for u128→u64 trace IDs
The truncation is intentional — Datadog protocol transmits the lower 64 bits via x-datadog-trace-id, with upper bits in _dd.p.tid tag.
1 parent f4c85cc commit baf4f6f

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

bottlecap/src/lifecycle/invocation/processor.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,10 @@ impl Processor {
980980

981981
// Set the extracted trace context to the spans
982982
if let Some(sc) = &context.extracted_span_context {
983-
context.invocation_span.trace_id = sc.trace_id as u64;
983+
#[allow(clippy::cast_possible_truncation)] // Datadog protocol uses lower 64 bits
984+
{
985+
context.invocation_span.trace_id = sc.trace_id as u64;
986+
}
984987
context.invocation_span.parent_id = sc.span_id;
985988

986989
// Set the right data to the correct root level span,
@@ -1210,7 +1213,10 @@ impl Processor {
12101213
// If we have a trace context, this means we got it from
12111214
// distributed tracing
12121215
if let Some(sc) = &context.extracted_span_context {
1213-
trace_id = sc.trace_id as u64;
1216+
#[allow(clippy::cast_possible_truncation)] // Datadog protocol uses lower 64 bits
1217+
{
1218+
trace_id = sc.trace_id as u64;
1219+
}
12141220
parent_id = sc.span_id;
12151221
tags.extend(sc.tags.clone());
12161222
}

bottlecap/src/lifecycle/listener.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,14 @@ impl Listener {
218218
fn inject_span_context_to_headers(headers: &mut HeaderMap, span_context: &SpanContext) {
219219
headers.insert(
220220
DATADOG_TRACE_ID_KEY,
221-
(span_context.trace_id as u64)
222-
.to_string()
223-
.parse()
224-
.expect("Failed to parse trace id"),
221+
{
222+
#[allow(clippy::cast_possible_truncation)] // Datadog protocol uses lower 64 bits
223+
let trace_id = span_context.trace_id as u64;
224+
trace_id
225+
}
226+
.to_string()
227+
.parse()
228+
.expect("Failed to parse trace id"),
225229
);
226230

227231
if let Some(priority) = span_context.sampling.priority {

0 commit comments

Comments
 (0)