Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(error-tracking): support versioned fingerprint algorithms in cymbal (#67986)

Hugues Pouillotb1e59f4483e3
diff --git a/rust/cymbal/src/modes/processing/fingerprinting/mod.rs b/rust/cymbal/src/modes/processing/fingerprinting/mod.rs
index 63f72c68ca6e..a4aa4129536e 100644
--- a/rust/cymbal/src/modes/processing/fingerprinting/mod.rs
+++ b/rust/cymbal/src/modes/processing/fingerprinting/mod.rs
@@ -79,6 +79,30 @@ impl Fingerprint {
}
}
+// Versions of the automatic fingerprint algorithm. The grouping stage computes every
+// registered version for each event, keeps the newest version already used by an existing issue,
+// and falls back to the newest version for new issues. Adding a version = one variant + one arm
+// in `compute()` + appending to `all()`.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum FingerprintVersion {
+ V1,
+}
+
+impl FingerprintVersion {
+ // All registered versions, ascending. Order is meaningful: selection keeps the newest
+ // already-used fingerprint, and new issues are created under the last (newest) entry.
+ pub fn all() -> &'static [FingerprintVersion] {
+ &[FingerprintVersion::V1]
+ }
+
+ pub fn compute(&self, exception_list: &ExceptionList) -> Fingerprint {
+ match self {
+ FingerprintVersion::V1 => Fingerprint::from_exception_list(exception_list),
+ }
+ }
+}
+
impl FingerprintComponent for crate::frames::Frame {
fn update(&self, fp: &mut FingerprintBuilder) {
let get_part = |s: &common_types::error_tracking::FrameId, p: Vec<&str>| {
diff --git a/rust/cymbal/src/modes/processing/stages/grouping/fingerprint.rs b/rust/cymbal/src/modes/processing/stages/grouping/fingerprint.rs
index 1e8d02f5a2df..c8c516241eba 100644
--- a/rust/cymbal/src/modes/processing/stages/grouping/fingerprint.rs
+++ b/rust/cymbal/src/modes/processing/stages/grouping/fingerprint.rs
@@ -2,7 +2,8 @@ use sha2::{Digest, Sha512};
use crate::{
error::UnhandledError,
- fingerprinting::{Fingerprint, FingerprintRecordPart},
+ fingerprinting::{Fingerprint, FingerprintRecordPart, FingerprintVersion},
+ issue_resolution::IssueFingerprintOverride,
metric_consts::FINGERPRINT_GENERATOR_OPERATOR,
modes::processing::rules::grouping::evaluate_grouping_rules,
stages::{grouping::GroupingStage, pipeline::HandledError},
@@ -30,35 +31,95 @@ impl ValueOperator for FingerprintGenerator {
mut input: ExceptionProperties,
ctx: GroupingStage,
) -> OperatorResult<Self> {
- // Generate fingerprint (uses resolved frames for hashing, or applies grouping rules).
+ // Selection order:
+ // 1. Existing input fingerprint wins and is marked manual.
+ // 2. Matching grouping rule wins and is marked custom.
+ // 3. Automatic versions use the newest already-saved fingerprint, or the newest version.
+ // Manual and rule fingerprints intentionally do not set a fingerprint version.
+ if input.fingerprint.is_some() {
+ apply_manual_fingerprint(&mut input)?;
+ return Ok(Ok(input));
+ }
+
// Serializing the event to JSON is only needed when the team has grouping rules, so
// defer it: `evaluate_grouping_rules` invokes this closure only when rules exist.
- let fingerprint: Fingerprint =
- match evaluate_grouping_rules(&ctx.connection, input.team_id, &ctx.team_manager, || {
+ let matched_rule =
+ evaluate_grouping_rules(&ctx.connection, input.team_id, &ctx.team_manager, || {
Ok(serde_json::to_value(&input)?)
})
- .await?
- {
- Some(rule) => Fingerprint::from_rule(rule),
- None => Fingerprint::from_exception_list(&input.exception_list),
- };
-
- // Always set proposed_fingerprint to the computed value
- input.proposed_fingerprint = Some(fingerprint.value.clone());
-
- // User sent us a custom fingerprint, let's use it.
- if let Some(fp) = &input.fingerprint {
- input.fingerprint_record = Some(vec![FingerprintRecordPart::Manual]);
- if fp.len() > 64 {
- let mut hasher = Sha512::default();
- hasher.update(fp);
- input.fingerprint = Some(format!("{:x}", hasher.finalize()));
- }
- } else {
+ .await?;
+
+ if let Some(rule) = matched_rule {
+ let fingerprint = Fingerprint::from_rule(rule);
input.fingerprint = Some(fingerprint.value);
+ input.fingerprint_version = None;
input.fingerprint_record = Some(fingerprint.record);
+ return Ok(Ok(input));
}
+ let (version, fingerprint) = select_automatic_fingerprint(&input, &ctx).await?;
+ input.fingerprint = Some(fingerprint.value);
+ input.fingerprint_record = Some(fingerprint.record);
+ input.fingerprint_version = Some(version);
+
Ok(Ok(input))
}
}
+
+fn apply_manual_fingerprint(input: &mut ExceptionProperties) -> Result<(), UnhandledError> {
+ let Some(fp) = &input.fingerprint else {
+ return Err(UnhandledError::Other("Missing manual fingerprint".into()));
+ };
+ input.fingerprint_version = None;
+ input.fingerprint_record = Some(vec![FingerprintRecordPart::Manual]);
+ if fp.len() > 64 {
+ let mut hasher = Sha512::default();
+ hasher.update(fp);
+ input.fingerprint = Some(format!("{:x}", hasher.finalize()));
+ }
+ Ok(())
+}
+
+async fn select_automatic_fingerprint(
+ input: &ExceptionProperties,
+ ctx: &GroupingStage,
+) -> Result<(FingerprintVersion, Fingerprint), UnhandledError> {
+ let fingerprints = FingerprintVersion::all()
+ .iter()
+ .map(|version| (*version, version.compute(&input.exception_list)))
+ .collect::<Vec<_>>();
+ let newest = fingerprints
+ .last()
+ .cloned()
+ .ok_or_else(|| UnhandledError::Other("No fingerprint algorithms registered".into()))?;
+
+ for (version, fingerprint) in fingerprints.into_iter().rev() {
+ if fingerprint_exists(ctx, input.team_id, &fingerprint.value).await? {
+ return Ok((version, fingerprint));
+ }
+ }
+
+ Ok(newest)
+}
+
+async fn fingerprint_exists(
+ ctx: &GroupingStage,
+ team_id: i32,
+ fingerprint: &str,
+) -> Result<bool, UnhandledError> {
+ let cache_key = (team_id, fingerprint.to_string());
+ if ctx.issue_cache.get(&cache_key).await.is_some() {
+ return Ok(true);
+ }
+
+ let Some(override_record) =
+ IssueFingerprintOverride::load(&ctx.connection, team_id, fingerprint).await?
+ else {
+ return Ok(false);
+ };
+
+ ctx.issue_cache
+ .insert(cache_key, override_record.issue_id)
+ .await;
+ Ok(true)
+}
diff --git a/rust/cymbal/src/modes/processing/stages/grouping/mod.rs b/rust/cymbal/src/modes/processing/stages/grouping/mod.rs
index 75bc949a6b36..2fc8b4f8ecac 100644
--- a/rust/cymbal/src/modes/processing/stages/grouping/mod.rs
+++ b/rust/cymbal/src/modes/processing/stages/grouping/mod.rs
@@ -1,6 +1,8 @@
use std::sync::Arc;
+use moka::future::Cache;
use sqlx::PgPool;
+use uuid::Uuid;
pub mod fingerprint;
@@ -10,13 +12,14 @@ use crate::{
metric_consts::GROUPING_STAGE,
stages::{grouping::fingerprint::FingerprintGenerator, pipeline::ExceptionEventPipelineItem},
teams::TeamManager,
- types::{batch::Batch, stage::Stage},
+ types::{batch::Batch, operator::TeamId, stage::Stage},
};
#[derive(Clone)]
pub struct GroupingStage {
pub connection: PgPool,
pub team_manager: TeamManager,
+ pub issue_cache: Cache<(TeamId, String), Uuid>,
}
impl From<&Arc<AppContext>> for GroupingStage {
@@ -24,6 +27,7 @@ impl From<&Arc<AppContext>> for GroupingStage {
Self {
connection: ctx.posthog_pool.clone(),
team_manager: ctx.team_manager.clone(),
+ issue_cache: ctx.issue_cache.clone(),
}
}
}
diff --git a/rust/cymbal/src/modes/processing/stages/linking/issue.rs b/rust/cymbal/src/modes/processing/stages/linking/issue.rs
index 92d1fcb1f578..83c7c9da8b10 100644
--- a/rust/cymbal/src/modes/processing/stages/linking/issue.rs
+++ b/rust/cymbal/src/modes/processing/stages/linking/issue.rs
@@ -68,7 +68,10 @@ impl ValueOperator for IssueLinker {
}
async fn execute_value(&self, input: Self::Item, ctx: LinkingStage) -> OperatorResult<Self> {
- let fingerprint = input.fingerprint.clone().unwrap();
+ let fingerprint = input
+ .fingerprint
+ .clone()
+ .ok_or_else(|| UnhandledError::Other("Missing fingerprint".into()))?;
let key = (input.team_id, fingerprint);
// Wrap the (large) event in an `Arc` so the cache-loader closures capture a cheap
@@ -118,7 +121,10 @@ async fn resolve_via_id_cache(
input: Arc<ExceptionProperties>,
ctx: &LinkingStage,
) -> Result<Issue, UnhandledError> {
- let fingerprint = input.fingerprint.clone().unwrap();
+ let fingerprint = input
+ .fingerprint
+ .clone()
+ .ok_or_else(|| UnhandledError::Other("Missing fingerprint".into()))?;
let key = (input.team_id, fingerprint.clone());
// `try_get_with` only returns the cached value (`Uuid`), so we stash the freshly
diff --git a/rust/cymbal/src/modes/processing/stages/linking/mod.rs b/rust/cymbal/src/modes/processing/stages/linking/mod.rs
index 72ff7101256a..e8aeadb08e54 100644
--- a/rust/cymbal/src/modes/processing/stages/linking/mod.rs
+++ b/rust/cymbal/src/modes/processing/stages/linking/mod.rs
@@ -29,9 +29,9 @@ pub struct LinkingStage {
pub app_context: Arc<AppContext>,
// Cross-batch `(team_id, fingerprint) -> issue_id` mapping cache. Owned by AppContext.
pub issue_cache: Cache<(TeamId, String), Uuid>,
- // Per-batch fingerprint -> Issue dedup. Built fresh per batch (LinkingStage is
- // constructed per batch via `From`), so events sharing a fingerprint within a single
- // batch resolve the Issue exactly once. moka's `try_get_with` also deduplicates
+ // Per-batch fingerprints -> resolved issue dedup. Built fresh per batch (LinkingStage is
+ // constructed per batch via `From`), so events sharing candidate fingerprints within a
+ // single batch resolve the Issue exactly once. moka's `try_get_with` also deduplicates
// concurrent misses for the same key inside the same batch.
pub batch_issue_cache: Cache<(TeamId, String), Issue>,
}
diff --git a/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs b/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs
index 2ebe54f699d4..ea531899dbe6 100644
--- a/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs
+++ b/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs
@@ -658,6 +658,7 @@ mod tests {
exception_handled: None,
exception_releases: HashMap::new(),
fingerprint: None,
+ fingerprint_version: None,
proposed_fingerprint: None,
fingerprint_record: None,
issue_id,
diff --git a/rust/cymbal/src/modes/processing/types/exception_properties.rs b/rust/cymbal/src/modes/processing/types/exception_properties.rs
index dcf7819a21fe..4e71b1a77744 100644
--- a/rust/cymbal/src/modes/processing/types/exception_properties.rs
+++ b/rust/cymbal/src/modes/processing/types/exception_properties.rs
@@ -7,7 +7,7 @@ use uuid::Uuid;
use crate::{
error::{EventError, UnhandledError},
- fingerprinting::FingerprintRecordPart,
+ fingerprinting::{FingerprintRecordPart, FingerprintVersion},
frames::releases::ReleaseInfo,
issue_resolution::Issue,
langs::native::DebugImage,
@@ -42,7 +42,13 @@ pub struct ExceptionProperties {
#[serde(rename = "$exception_fingerprint")]
pub fingerprint: Option<String>,
- #[serde(rename = "$exception_proposed_fingerprint")]
+ #[serde(
+ rename = "$exception_fingerprint_version",
+ skip_serializing_if = "Option::is_none"
+ )]
+ pub fingerprint_version: Option<FingerprintVersion>,
+ // Deprecated: accepted for old events but no longer emitted.
+ #[serde(rename = "$exception_proposed_fingerprint", skip_serializing)]
pub proposed_fingerprint: Option<String>,
#[serde(rename = "$exception_fingerprint_record")]
pub fingerprint_record: Option<Vec<FingerprintRecordPart>>,
@@ -105,15 +111,10 @@ impl ExceptionProperties {
.fingerprint
.clone()
.ok_or_else(|| UnhandledError::Other("Missing fingerprint".into()))?;
- let proposed_fingerprint = self
- .proposed_fingerprint
- .clone()
- .ok_or_else(|| UnhandledError::Other("Missing proposed_fingerprint".into()))?;
-
Ok(OutputErrProps {
exception_list: self.exception_list.clone(),
fingerprint,
- proposed_fingerprint,
+ fingerprint_version: self.fingerprint_version,
fingerprint_record: self.fingerprint_record.clone().unwrap_or_default(),
issue_id,
other: self.props.clone(),
diff --git a/rust/cymbal/src/modes/processing/types/mod.rs b/rust/cymbal/src/modes/processing/types/mod.rs
index e26d3fa430ee..3a9c76afa3eb 100644
--- a/rust/cymbal/src/modes/processing/types/mod.rs
+++ b/rust/cymbal/src/modes/processing/types/mod.rs
@@ -6,7 +6,9 @@ use std::hash::Hash;
use std::ops::{Deref, DerefMut};
use uuid::Uuid;
-use crate::fingerprinting::{FingerprintBuilder, FingerprintComponent, FingerprintRecordPart};
+use crate::fingerprinting::{
+ FingerprintBuilder, FingerprintComponent, FingerprintRecordPart, FingerprintVersion,
+};
use crate::frames::releases::{ReleaseInfo, ReleaseRecord};
use crate::frames::{Frame, RawFrame};
use crate::langs::native::DebugImage;
@@ -151,8 +153,11 @@ pub struct OutputErrProps {
pub exception_list: ExceptionList,
#[serde(rename = "$exception_fingerprint")]
pub fingerprint: String,
- #[serde(rename = "$exception_proposed_fingerprint")]
- pub proposed_fingerprint: String,
+ #[serde(
+ rename = "$exception_fingerprint_version",
+ skip_serializing_if = "Option::is_none"
+ )]
+ pub fingerprint_version: Option<FingerprintVersion>,
#[serde(rename = "$exception_fingerprint_record")]
pub fingerprint_record: Vec<FingerprintRecordPart>,
#[serde(rename = "$exception_issue_id")]
diff --git a/rust/cymbal/tests/common/mod.rs b/rust/cymbal/tests/common/mod.rs
index f79048d1840d..dd80b14d9c04 100644
--- a/rust/cymbal/tests/common/mod.rs
+++ b/rust/cymbal/tests/common/mod.rs
@@ -489,6 +489,7 @@ pub fn build_event(num_exceptions: usize) -> ExceptionProperties {
exception_handled: None,
exception_releases: Default::default(),
fingerprint: None,
+ fingerprint_version: None,
proposed_fingerprint: None,
fingerprint_record: None,
issue_id: None,
diff --git a/rust/cymbal/tests/event.rs b/rust/cymbal/tests/event.rs
index 13a348d70b49..2212a3ff06a4 100644
--- a/rust/cymbal/tests/event.rs
+++ b/rust/cymbal/tests/event.rs
@@ -17,7 +17,7 @@ use mockall::predicate;
use posthog_symbol_data::{write_symbol_data, SourceAndMap};
use reqwest::StatusCode;
use serde::{de::DeserializeOwned, Deserialize};
-use serde_json::json;
+use serde_json::{json, Value as JsonValue};
use sqlx::PgPool;
use uuid::Uuid;
@@ -639,3 +639,131 @@ async fn remote_resolution_http_process_streams_same_team_events_as_items(db: Pg
.iter()
.any(|payload| payload.contains("\"chunk_id\":\"124\"")));
}
+
+// ---- Versioned fingerprinting: used-fingerprint semantics ----
+
+fn resolved_stack_event(source: &str) -> AnyEvent {
+ make_event(vec![make_exception_with_stack(
+ "Error",
+ "boom",
+ vec![frame_at(make_frame_js("handleClick"), source, 42, 10)],
+ )])
+}
+
+fn grouping_rule_bytecode() -> JsonValue {
+ // return properties.test_value = 'test_value'
+ json!([
+ "_H",
+ 1,
+ 32,
+ "test_value",
+ 32,
+ "test_value",
+ 32,
+ "properties",
+ 1,
+ 2,
+ 11,
+ 38
+ ])
+}
+
+async fn insert_grouping_rule(db: &PgPool) -> Uuid {
+ let id = Uuid::now_v7();
+ let bytecode = grouping_rule_bytecode();
+ sqlx::query(
+ r#"
+ INSERT INTO posthog_errortrackinggroupingrule
+ (id, team_id, order_key, bytecode, created_at, updated_at)
+ VALUES ($1, 1, 0, $2, NOW(), NOW())
+ "#,
+ )
+ .bind(id)
+ .bind(&bytecode)
+ .execute(db)
+ .await
+ .unwrap();
+ id
+}
+
+#[sqlx::test(migrations = "./tests/test_migrations")]
+async fn new_issue_uses_newest_fingerprint_version(db: PgPool) {
+ let harness = TestHarness::new(db);
+ let input = resolved_stack_event("src/app.js");
+
+ let (status, body): (_, SuccessResponse) = harness.post_event(&input).await;
+ assert!(status.is_success());
+
+ let event = body.first_event().as_ref().unwrap();
+ assert!(event.properties.get("$exception_fingerprints").is_none());
+ assert!(event
+ .properties
+ .get("$exception_proposed_fingerprint")
+ .is_none());
+ assert_eq!(
+ event.properties["$exception_fingerprint_version"],
+ json!("v1")
+ );
+}
+
+#[sqlx::test(migrations = "./tests/test_migrations")]
+async fn manual_fingerprint_keeps_custom_value(db: PgPool) {
+ let harness = TestHarness::new(db);
+ let mut input = make_event_with_options(
+ vec![make_exception("TypeError", "cannot read property")],
+ Some("custom-fingerprint"),
+ None,
+ );
+ input.properties["$exception_fingerprint_version"] = json!("v1");
+
+ let (_, body): (_, SuccessResponse) = harness.post_event(&input).await;
+ let event = body.first_event().as_ref().unwrap();
+
+ assert_eq!(
+ event.properties["$exception_fingerprint"],
+ "custom-fingerprint"
+ );
+ assert_eq!(
+ event.properties["$exception_fingerprint_record"],
+ serde_json::json!([{ "type": "manual" }])
+ );
+
+ assert!(event.properties.get("$exception_fingerprints").is_none());
+ assert!(event
+ .properties
+ .get("$exception_proposed_fingerprint")
+ .is_none());
+ assert!(event
+ .properties
+ .get("$exception_fingerprint_version")
+ .is_none());
+}
+
+#[sqlx::test(migrations = "./tests/test_migrations")]
+async fn grouping_rule_sets_custom_fingerprint_without_proposed_fingerprint(db: PgPool) {
+ let harness = TestHarness::new(db.clone());
+ let rule_id = insert_grouping_rule(&db).await;
+ let mut input = make_event(vec![make_exception("TypeError", "cannot read property")]);
+ input.properties["test_value"] = json!("test_value");
+ input.properties["$exception_fingerprint_version"] = json!("v1");
+
+ let (_, body): (_, SuccessResponse) = harness.post_event(&input).await;
+ let event = body.first_event().as_ref().unwrap();
+
+ assert_eq!(
+ event.properties["$exception_fingerprint"],
+ json!(format!("custom-rule:{rule_id}"))
+ );
+ assert!(event
+ .properties
+ .get("$exception_proposed_fingerprint")
+ .is_none());
+ assert!(event
+ .properties
+ .get("$exception_fingerprint_version")
+ .is_none());
+ assert_eq!(
+ event.properties["$exception_fingerprint_record"],
+ json!([{ "type": "custom", "rule_id": rule_id }])
+ );
+}
diff --git a/rust/cymbal/tests/fingerprint_golden.rs b/rust/cymbal/tests/fingerprint_golden.rs
new file mode 100644
index 000000000000..19dbf6b31dfd
--- /dev/null
+++ b/rust/cymbal/tests/fingerprint_golden.rs
@@ -0,0 +1,254 @@
+//! Golden tests pinning the automatic fingerprint algorithm bit-for-bit.
+//!
+//! The snapshots were recorded against the pre-`FingerprintStrategy` implementation, so any
+//! refactor of the fingerprinting code must reproduce them exactly — both the SHA-512 `value`
+//! and the user-facing `record`. A change here re-groups live error-tracking issues; treat a
+//! snapshot diff as a data-migration concern, never an "accept and move on".
+
+use common_types::error_tracking::FrameId;
+use common_types::ClickHouseEvent;
+use cymbal::fingerprinting::Fingerprint;
+use cymbal::frames::Frame;
+use cymbal::types::{Exception, RawErrProps, Stacktrace};
+
+#[allow(clippy::too_many_arguments)]
+fn frame(
+ mangled: &str,
+ source: Option<&str>,
+ module: Option<&str>,
+ resolved_name: Option<&str>,
+ resolved: bool,
+ in_app: bool,
+ line: Option<u32>,
+ column: Option<u32>,
+) -> Frame {
+ Frame {
+ frame_id: FrameId::new(String::new(), 1, 0),
+ mangled_name: mangled.to_string(),
+ line,
+ column,
+ source: source.map(String::from),
+ in_app,
+ resolved_name: resolved_name.map(String::from),
+ resolved,
+ resolve_failure: None,
+ lang: "javascript".to_string(),
+ junk_drawer: None,
+ code_variables: None,
+ context: None,
+ release: None,
+ synthetic: false,
+ suspicious: false,
+ module: module.map(String::from),
+ }
+}
+
+fn exception(exc_type: &str, message: &str, stack: Option<Stacktrace>) -> Exception {
+ Exception {
+ exception_id: Some("00000000-0000-0000-0000-000000000000".to_string()),
+ exception_type: exc_type.to_string(),
+ exception_message: message.to_string(),
+ mechanism: Default::default(),
+ module: Default::default(),
+ thread_id: None,
+ stack,
+ }
+}
+
+fn resolved_stack(frames: Vec<Frame>) -> Option<Stacktrace> {
+ Some(Stacktrace::Resolved { frames })
+}
+
+fn snapshot(name: &str, exceptions: Vec<Exception>) {
+ let fingerprint = Fingerprint::from_exception_list(&exceptions.into());
+ insta::assert_json_snapshot!(name, fingerprint);
+}
+
+#[test]
+fn golden_no_stack() {
+ snapshot(
+ "no_stack",
+ vec![exception(
+ "TypeError",
+ "Cannot read property 'foo' of undefined",
+ None,
+ )],
+ );
+}
+
+#[test]
+fn golden_raw_stack_uses_type_and_message() {
+ // A raw (unresolved-typed) stack contributes nothing beyond type + message.
+ let raw_frame = serde_json::from_value(serde_json::json!({
+ "platform": "web:javascript",
+ "function": "eF",
+ "filename": "chunk-PGUQKT6S.js",
+ "lineno": 64,
+ "colno": 25112,
+ "in_app": true
+ }))
+ .expect("valid raw JS frame");
+ snapshot(
+ "raw_stack",
+ vec![exception(
+ "ReferenceError",
+ "x is not defined",
+ Some(Stacktrace::Raw {
+ frames: vec![raw_frame],
+ }),
+ )],
+ );
+}
+
+#[test]
+fn golden_all_resolved_in_app() {
+ snapshot(
+ "all_resolved_in_app",
+ vec![exception(
+ "TypeError",
+ "Cannot read property 'foo' of undefined",
+ resolved_stack(vec![
+ frame(
+ "foo",
+ Some("http://example.com/alpha/foo.js"),
+ None,
+ Some("bar"),
+ true,
+ true,
+ Some(10),
+ Some(5),
+ ),
+ frame(
+ "bar",
+ Some("http://example.com/bar.js"),
+ Some("app.module"),
+ Some("baz"),
+ true,
+ true,
+ Some(20),
+ Some(15),
+ ),
+ ]),
+ )],
+ );
+}
+
+#[test]
+fn golden_mixed_resolved_unresolved_ignores_unresolved() {
+ snapshot(
+ "mixed_resolved_unresolved",
+ vec![exception(
+ "TypeError",
+ "Cannot read property 'foo' of undefined",
+ resolved_stack(vec![
+ frame(
+ "foo",
+ Some("http://example.com/alpha/foo.js"),
+ None,
+ Some("bar"),
+ true,
+ true,
+ Some(10),
+ Some(5),
+ ),
+ frame("xyz", None, None, None, false, true, Some(30), Some(25)),
+ ]),
+ )],
+ );
+}
+
+#[test]
+fn golden_no_resolved_frames_uses_all_in_app() {
+ snapshot(
+ "no_resolved_frames",
+ vec![exception(
+ "TypeError",
+ "Cannot read property 'foo' of undefined",
+ resolved_stack(vec![
+ frame(
+ "foo",
+ Some("http://example.com/alpha/foo.js"),
+ None,
+ None,
+ false,
+ true,
+ Some(10),
+ Some(5),
+ ),
+ frame("xyz", None, None, None, false, true, Some(30), Some(25)),
+ ]),
+ )],
+ );
+}
+
+#[test]
+fn golden_no_in_app_frames_uses_first_frame() {
+ snapshot(
+ "no_in_app_frames",
+ vec![exception(
+ "TypeError",
+ "Cannot read property 'foo' of undefined",
+ resolved_stack(vec![
+ frame(
+ "vendor_a",
+ Some("http://example.com/vendor.js"),
+ None,
+ Some("vendorA"),
+ true,
+ false,
+ Some(1),
+ Some(2),
+ ),
+ frame(
+ "vendor_b",
+ Some("http://example.com/vendor.js"),
+ None,
+ Some("vendorB"),
+ true,
+ false,
+ Some(3),
+ Some(4),
+ ),
+ ]),
+ )],
+ );
+}
+
+#[test]
+fn golden_chained_exceptions() {
+ snapshot(
+ "chained_exceptions",
+ vec![
+ exception(
+ "WrapperError",
+ "wrapped",
+ resolved_stack(vec![frame(
+ "outer",
+ Some("http://example.com/outer.js"),
+ None,
+ Some("outerFn"),
+ true,
+ true,
+ Some(1),
+ Some(1),
+ )]),
+ ),
+ exception("RootError", "root cause", None),
+ ],
+ );
+}
+
+#[test]
+fn golden_static_raw_ch_exception_list() {
+ // Real capture-shaped event: `properties` is a JSON string holding RawErrProps.
+ let event: ClickHouseEvent =
+ serde_json::from_str(include_str!("./static/raw_ch_exception_list.json"))
+ .expect("valid ClickHouseEvent fixture");
+ let props: RawErrProps =
+ serde_json::from_str(event.properties.as_deref().expect("fixture has properties"))
+ .expect("valid RawErrProps");
+ snapshot(
+ "static_raw_ch_exception_list",
+ props.exception_list.iter().cloned().collect(),
+ );
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__all_resolved_in_app.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__all_resolved_in_app.snap
new file mode 100644
index 000000000000..86b7664facd6
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__all_resolved_in_app.snap
@@ -0,0 +1,33 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "d03a8ead4f42a8a315039e016979d6ded265ca61ebe08c5114b17626dc285f133e6a62b80d8122ff6b34198223f75bc4a682968b3608f97e9b341da4a1cc3dec",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Source file name",
+ "Resolved function name"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Source file name",
+ "Module name",
+ "Resolved function name"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__chained_exceptions.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__chained_exceptions.snap
new file mode 100644
index 000000000000..fd66696486cf
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__chained_exceptions.snap
@@ -0,0 +1,32 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "6eee563d6d6696de053d8e06bbe9730ba056cf8778441bb38565daf10750791fc241e64de2c3a990b4381b9ff9ee5c89533348f258d736b13b14157134989226",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Source file name",
+ "Resolved function name"
+ ]
+ },
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type",
+ "Exception Message"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__mixed_resolved_unresolved.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__mixed_resolved_unresolved.snap
new file mode 100644
index 000000000000..75d8927589c9
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__mixed_resolved_unresolved.snap
@@ -0,0 +1,24 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "6e90a17bb9377cf9a1c0da2d7d232684d83a3cbcdc5aa274446ac29a8a2fbf183ae1a46a398893e9f7e13c19725b3a0c5106458955849d901b1f9802974a15e0",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Source file name",
+ "Resolved function name"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__no_in_app_frames.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__no_in_app_frames.snap
new file mode 100644
index 000000000000..124180d8ec0e
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__no_in_app_frames.snap
@@ -0,0 +1,24 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "1788821bac39fa21171ae3e767263fb24ebb6c5d76298f47de8c4b64d165db44a26600e7c9b3b089ab3cb62b0c4d46e1be01f8963040d4016c266478194789aa",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Source file name",
+ "Resolved function name"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__no_resolved_frames.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__no_resolved_frames.snap
new file mode 100644
index 000000000000..5b0e54dffc51
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__no_resolved_frames.snap
@@ -0,0 +1,37 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "3d5a74c21354d860d03b40d21a26f77cd818977efe11d4c27a082f2d3f030199f45d95841480b3ccee1376ed27f0bfa6426ef28227a469c3a67570b3edd87ded",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Source file name",
+ "Mangled function name",
+ "Line number",
+ "Column number",
+ "Language"
+ ]
+ },
+ {
+ "type": "frame",
+ "raw_id": "/0",
+ "pieces": [
+ "Mangled function name",
+ "Line number",
+ "Column number",
+ "Language"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__no_stack.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__no_stack.snap
new file mode 100644
index 000000000000..41f55aed4581
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__no_stack.snap
@@ -0,0 +1,17 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "2cb3f141543f0a80f04e8eede5c890e62baea0357447390eeffcdc6ea047470c76e266df76bdcdb8232e951701b3187942435e75ce384094b8ae192a867e8c61",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type",
+ "Exception Message"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__raw_stack.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__raw_stack.snap
new file mode 100644
index 000000000000..621d58bcaa6e
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__raw_stack.snap
@@ -0,0 +1,17 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "cfe0ff85d4b448eab8e16c928f8dac7b9758900752626b26e8e8bfc94c9974e8c3235b79c664518a933a6e099137eb2854c66644b582bb1c7eb66eb9d966df08",
+ "record": [
+ {
+ "type": "exception",
+ "id": "00000000-0000-0000-0000-000000000000",
+ "pieces": [
+ "Exception Type",
+ "Exception Message"
+ ]
+ }
+ ]
+}
diff --git a/rust/cymbal/tests/snapshots/fingerprint_golden__static_raw_ch_exception_list.snap b/rust/cymbal/tests/snapshots/fingerprint_golden__static_raw_ch_exception_list.snap
new file mode 100644
index 000000000000..ca836affc514
--- /dev/null
+++ b/rust/cymbal/tests/snapshots/fingerprint_golden__static_raw_ch_exception_list.snap
@@ -0,0 +1,17 @@
+---
+source: cymbal/tests/fingerprint_golden.rs
+expression: fingerprint
+---
+{
+ "value": "51e4786f1a486b004f9a1f023074954722e48cca7f9205f11c0c851639e0247956209ad8cb2eb31c0809cd4eeaee1da7035b3f44e25575a9c0f1f2413b5c353b",
+ "record": [
+ {
+ "type": "exception",
+ "id": null,
+ "pieces": [
+ "Exception Type",
+ "Exception Message"
+ ]
+ }
+ ]
+}