From 3bd9b938352af3fc31de9aa40a67ef1d07adfab6 Mon Sep 17 00:00:00 2001 From: Oliver Browne Date: Wed, 4 Dec 2024 15:42:21 +0200 Subject: [PATCH] fix(err): support fingerprint passthrough (#26639) --- rust/cymbal/src/types/mod.rs | 12 +++++++++++- rust/cymbal/tests/static/python_err_props.json | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rust/cymbal/src/types/mod.rs b/rust/cymbal/src/types/mod.rs index 01850217127f0..9e2354494e339 100644 --- a/rust/cymbal/src/types/mod.rs +++ b/rust/cymbal/src/types/mod.rs @@ -49,6 +49,11 @@ pub struct Exception { pub struct RawErrProps { #[serde(rename = "$exception_list")] pub exception_list: Vec, + #[serde( + rename = "$exception_fingerprint", + skip_serializing_if = "Option::is_none" + )] + pub fingerprint: Option, // Clients can send us fingerprints, which we'll use if present #[serde(flatten)] // A catch-all for all the properties we don't "care" about, so when we send back to kafka we don't lose any info pub other: HashMap, @@ -57,6 +62,7 @@ pub struct RawErrProps { pub struct FingerprintedErrProps { pub exception_list: Vec, pub fingerprint: String, + pub proposed_fingerprint: String, // We suggest a fingerprint, based on hashes, but let users override client-side pub other: HashMap, } @@ -67,6 +73,8 @@ pub struct OutputErrProps { pub exception_list: Vec, #[serde(rename = "$exception_fingerprint")] pub fingerprint: String, + #[serde(rename = "$exception_proposed_fingerprint")] + pub proposed_fingerprint: String, #[serde(rename = "$exception_issue_id")] pub issue_id: Uuid, #[serde(flatten)] @@ -119,7 +127,8 @@ impl RawErrProps { pub fn to_fingerprinted(self, fingerprint: String) -> FingerprintedErrProps { FingerprintedErrProps { exception_list: self.exception_list, - fingerprint, + fingerprint: self.fingerprint.unwrap_or(fingerprint.clone()), + proposed_fingerprint: fingerprint, other: self.other, } } @@ -131,6 +140,7 @@ impl FingerprintedErrProps { exception_list: self.exception_list, fingerprint: self.fingerprint, issue_id, + proposed_fingerprint: self.proposed_fingerprint, other: self.other, } } diff --git a/rust/cymbal/tests/static/python_err_props.json b/rust/cymbal/tests/static/python_err_props.json index 1a110b81964b1..df4caf67e728e 100644 --- a/rust/cymbal/tests/static/python_err_props.json +++ b/rust/cymbal/tests/static/python_err_props.json @@ -733,6 +733,5 @@ "$ip": "185.140.230.43", "$lib_version__minor": 6, "$lib": "posthog-python", - "$lib_version__major": 3, - "$exception_fingerprint": ["ConnectionRefusedError", "[Errno 111] Connection refused", "_new_conn"] + "$lib_version__major": 3 }