vectordotdev/vector · critical
`parent_id` should be an i64
Error message
`parent_id` should be an i64
What it means
extract_weight_from_root_span() in the datadog_traces sink walks the span list to find the root span and compute its sampling weight. It reads 'parent_id' (and sibling fields 'span_id'/'trace_id') expecting Value::Integer or None (absent parent_id means root); a present-but-non-integer value hits the catch-all and panics. Note 'trace_id' is stricter: for the first span it must be present as an integer, otherwise the panic fires too.
Source
Thrown at src/sinks/datadog/traces/apm_stats/weight.rs:29
// TODO this logic likely has a bug(s) that need to be root caused. The root span is not reliably found and defaults to "1.0"
// regularly for users even when sampling is disabled in the Agent.
// GH issue to track that: https://github.com/vectordotdev/vector/issues/14859
if spans.is_empty() {
return 1.0;
}
let mut trace_id: Option<usize> = None;
let mut parent_id_to_child_weight = BTreeMap::<i64, f64>::new();
let mut span_ids = Vec::<i64>::new();
for s in spans.iter() {
// TODO these need to change to u64 when the following issue is fixed:
// https://github.com/vectordotdev/vector/issues/14687
let parent_id = match s.get("parent_id") {
Some(Value::Integer(val)) => *val,
None => 0,
_ => panic!("`parent_id` should be an i64"),
};
let span_id = match s.get("span_id") {
Some(Value::Integer(val)) => *val,
None => 0,
_ => panic!("`span_id` should be an i64"),
};
if trace_id.is_none() {
trace_id = match s.get("trace_id") {
Some(Value::Integer(v)) => Some(*v as usize),
_ => panic!("`trace_id` should be an i64"),
}
}
let weight = s
.get("metrics")
.and_then(|m| m.as_object())
.map(|m| match m.get(SAMPLING_RATE_KEY) {
Some(Value::Float(v)) => {
let sample_rate = v.into_inner();View on GitHub (pinned to 3708c39b12)
Solutions
- Keep spans on a native path from source to datadog_traces sink with no serialization round-trips or field rewrites
- Where spans are constructed programmatically, write parent_id/span_id/trace_id as Value::Integer
- Upgrade Vector - trace ID typing fixes are tracked upstream; check the changelog
- Tap the stream (console sink) before the datadog sink to identify which spans carry non-integer IDs, then fix the producer
Example fix
// before
span.insert("parent_id", Value::from("12345")); // string id -> panic
// after: IDs are i64 in the span map
span.insert("parent_id", Value::Integer(12345)); Defensive patterns
Strategy: validation
Validate before calling
fn ids_ok(span: &ObjectMap) -> bool {
matches!(span.get("parent_id"), None | Some(Value::Integer(_)))
&& matches!(span.get("span_id"), None | Some(Value::Integer(_)))
&& matches!(span.get("trace_id"), Some(Value::Integer(_))) // first span must carry it
} Type guard
fn span_ids_are_i64(span: &ObjectMap) -> bool {
matches!(span.get("parent_id"), None | Some(Value::Integer(_)))
&& matches!(span.get("span_id"), None | Some(Value::Integer(_)))
} Prevention
- Write span ids as Value::Integer; never strings or floats
- Do not serialize/deserialize span maps through JSON between source and the datadog sink
- Ensure the first span of each trace carries an integer trace_id
- Upgrade Vector when trace ID handling fixes land (u64 work tracked in vectordotdev/vector#14687)
When it happens
Trigger: A span reaches the sink with 'parent_id' as a non-integer (float/string/bool) - e.g. IDs serialized through JSON as strings, or an OTLP mapping emitting 64-bit IDs as floats; or the first span lacking an integer 'trace_id'. The panic aborts APM stats computation for the batch.
Common situations: Trace pipelines that JSON-serialize/deserialize spans between source and sink (IDs become strings or lose integer precision); custom transforms re-inserting span ids with wrong types; version drift in OTLP ID handling (see vectordotdev/vector#14687 referenced in-code for the u64 follow-up).
Related errors
- `error` should be an i64
- `duration` should be an i64
- Failed type coercion, {self:?} is not a trace event
- Traces are not supported.
- message is required (make sure the "message" semantic meanin
AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20).
Data as JSON: /api/errors/fc69c9cd12bc7edb.
Report an issue: GitHub.