{"record":{"id":"e6cf5fc5373f8898","repo":"vectordotdev/vector","slug":"duration-should-be-an-i64","errorCode":null,"errorMessage":"`duration` should be an i64","messagePattern":"`duration` should be an i64","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/sinks/datadog/traces/apm_stats/bucket.rs","lineNumber":182,"sourceCode":"    /// Update a bucket with a new span. Computed statistics include the number of hits and the actual distribution of\n    /// execution time, with isolated measurements for spans flagged as errored and spans without error.\n    fn update(span: &ObjectMap, weight: f64, is_top: bool, gs: &mut GroupedStats) {\n        is_top.then(|| {\n            gs.top_level_hits += weight;\n        });\n        gs.hits += weight;\n        let error = match span.get(\"error\") {\n            Some(Value::Integer(val)) => *val,\n            None => 0,\n            _ => panic!(\"`error` should be an i64\"),\n        };\n        if error != 0 {\n            gs.errors += weight;\n        }\n        let duration = match span.get(\"duration\") {\n            Some(Value::Integer(val)) => *val,\n            None => 0,\n            _ => panic!(\"`duration` should be an i64\"),\n        };\n        gs.duration += (duration as f64) * weight;\n        if error != 0 {\n            gs.err_distribution.insert(duration as f64)\n        } else {\n            gs.ok_distribution.insert(duration as f64)\n        }\n    }\n}\n","sourceCodeStart":164,"sourceCodeEnd":192,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/sinks/datadog/traces/apm_stats/bucket.rs#L164-L192","documentation":"In the datadog_traces sink's APM stats bucket update, span['duration'] must be Value::Integer (nanoseconds) or absent (treated as 0); any other Value variant panics with '`duration` should be an i64'. The duration feeds both the total duration sum and the ok/err distributions, which are DDSketch-backed and expect f64 built from integers.","triggerScenarios":"A span arriving with 'duration' as a float, string, or bool - e.g. an OTLP span whose nanosecond duration was serialized as a JSON number that decoded to f64, or a transform that rewrote duration into a string. Absence is safe; presence with the wrong type panics.","commonSituations":"Non-Datadog-native trace sources feeding datadog_traces; serialization round-trips (JSON) that turn large i64 durations into floats; custom field mappings that mis-type duration; older Vector versions with incomplete span normalization.","solutions":["Use the canonical ingestion path (datadog_agent source / OTLP with Datadog normalization) so durations are decoded as integers","When constructing spans, insert duration as Value::Integer(nanoseconds)","Upgrade Vector and review the changelog for datadog traces fixes","Inspect the offending span (dump events with a console sink tapped before the datadog sink) to find which producer emits the wrong type"],"exampleFix":"// before\nspan.insert(\"duration\", Value::Float(1.5e6)); // -> panic\n\n// after: duration is i64 nanoseconds\nspan.insert(\"duration\", Value::Integer(1_500_000));","handlingStrategy":"validation","validationCode":"match span.get(\"duration\") {\n    None | Some(Value::Integer(_)) => {}\n    Some(other) => {\n        // normalize to i64 nanoseconds before the sink sees it\n        let ns = coerce_to_i64_ns(other).unwrap_or(0);\n        span.insert(\"duration\", Value::Integer(ns));\n    }\n}","typeGuard":"fn span_duration_is_i64(span: &ObjectMap) -> bool {\n    matches!(span.get(\"duration\"), None | Some(Value::Integer(_)))\n}","tryCatchPattern":null,"preventionTips":["Avoid JSON round-trips of spans between source and sink (floats replace large i64 durations)","Insert duration as Value::Integer nanoseconds when building spans","Keep trace pipelines native (no generic log transforms in the path)","Verify span field types in staging with a console sink tap before enabling apm stats"],"tags":["rust","vector","datadog","traces","apm-stats","type-mismatch","panic"],"backgroundTag":"event-field-type-mismatch","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}