{"record":{"id":"0c977e5ed267a654","repo":"vectordotdev/vector","slug":"error-should-be-an-i64","errorCode":null,"errorMessage":"`error` should be an i64","messagePattern":"`error` should be an i64","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/sinks/datadog/traces/apm_stats/bucket.rs","lineNumber":174,"sourceCode":"            None => {\n                let mut gs = GroupedStats::new();\n                Bucket::update(span, weight, is_top, &mut gs);\n                self.data.insert(aggkey, gs);\n            }\n        }\n    }\n\n    /// 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":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/sinks/datadog/traces/apm_stats/bucket.rs#L156-L192","documentation":"The datadog_traces sink computes APM statistics (hits, error counts, duration distributions) from each span's fields. update() reads span['error'] expecting Value::Integer or absent (absent defaults to 0); any other Value type - Boolean(true), Float, String, Map, etc. - hits the catch-all arm and panics, taking down the sink task. The Datadog span contract defines error as an integer flag (0/1), so a present-but-non-integer value means the span layout is not what the sink expects.","triggerScenarios":"A trace event reaches the datadog_traces sink whose span map carries 'error' as a non-integer, e.g. true (bool), \"1\" (string), or 1.0 (float). Common when spans were produced or mutated outside the canonical Datadog pipeline - OTLP ingestion with custom field mapping, remap/transforms touching span internals, or hand-built trace events in tests.","commonSituations":"Feeding datadog_traces from sources other than the datadog_agent source without full field normalization; VRL or Lua transforms rewriting span fields with non-integer types; version changes in the OTLP-to-Datadog span mapping; clients sending non-standard 'error' attribute types.","solutions":["Route traces into the sink through the supported path (datadog_agent source, or OTLP with Vector's Datadog span normalization) and do not mutate span-internal fields in transforms","If spans are built/modified programmatically, always set error as Value::Integer(0 or 1), never bool/string/float","Upgrade Vector - span field typing fixes have landed across releases; check the changelog for datadog traces/apm stats","If it persists, capture a sanitized span JSON that reproduces it and file an issue"],"exampleFix":"// before: building spans with a boolean error flag\nspan.insert(\"error\", Value::Boolean(true)); // -> panic in apm stats\n\n// after: Datadog APM stats require i64\nspan.insert(\"error\", Value::Integer(1));","handlingStrategy":"validation","validationCode":"// If you build or mutate span maps before the datadog_traces sink:\nmatch span.get(\"error\") {\n    None | Some(Value::Integer(_)) => {}\n    Some(_) => { span.insert(\"error\", Value::Integer(0)); /* normalize */ }\n}","typeGuard":"fn span_error_is_i64(span: &ObjectMap) -> bool {\n    matches!(span.get(\"error\"), None | Some(Value::Integer(_)))\n}","tryCatchPattern":null,"preventionTips":["Use the supported ingestion path (datadog_agent source / OTLP with Datadog normalization) so span field types are canonical","Never rewrite span-internal fields (error, duration, ids) in transforms with non-integer types","Set error strictly as integer 0/1 when constructing spans","Tap the stream with a console sink to inspect span field types when APM stats panics appear"],"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"}