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.

fix(error-tracking): skip fingerprint embeddings for manual fingerprints and elixir (#71471)

Hugues Pouillot032de6b49493
diff --git a/rust/cymbal/src/core/metric_consts.rs b/rust/cymbal/src/core/metric_consts.rs
index af892d8f5a93..0e2aced28cc0 100644
--- a/rust/cymbal/src/core/metric_consts.rs
+++ b/rust/cymbal/src/core/metric_consts.rs
@@ -108,6 +108,9 @@ pub const SIGNAL_EMITTED: &str = "cymbal_signal_emitted";
pub const SIGNAL_EMIT_FAILED: &str = "cymbal_signal_emit_failed";
pub const SIGNAL_EMIT_RESPONSE: &str = "cymbal_signal_emit_response";
+// Fingerprint embedding metrics
+pub const FINGERPRINT_EMBEDDING_SKIPPED: &str = "cymbal_fingerprint_embedding_skipped";
+
// Stages Name.
// We want to keep previous value for comparison, can be changed later on
pub const HTTP_EXCEPTION_PIPELINE: &str = "cymbal_http_exception_pipeline";
diff --git a/rust/cymbal/src/modes/notifications/side_effects.rs b/rust/cymbal/src/modes/notifications/side_effects.rs
index ebe44b0908d6..b13f36fb3ceb 100644
--- a/rust/cymbal/src/modes/notifications/side_effects.rs
+++ b/rust/cymbal/src/modes/notifications/side_effects.rs
@@ -4,13 +4,21 @@ use common_kafka::kafka_producer::{send_iter_to_kafka, KafkaContext, KafkaProduc
use common_types::embedding::{EmbeddingModel, EmbeddingRequest};
use rdkafka::producer::FutureProducer;
use rdkafka::types::RDKafkaErrorCode;
+use serde_json::Value;
+use tracing::debug;
use uuid::Uuid;
use crate::core::error::UnhandledError;
+use crate::metric_consts::FINGERPRINT_EMBEDDING_SKIPPED;
use crate::modes::notifications::stacktrace::print_stacktrace;
use crate::modes::notifications::types::NotificationIssue;
+use crate::modes::processing::fingerprinting::FingerprintRecordPart;
use crate::types::OutputErrProps;
+/// SDKs whose fingerprint embeddings we don't generate — they emit too many
+/// distinct issues, so embedding every fingerprint isn't worth the cost.
+const EMBEDDING_DISABLED_LIBS: &[&str] = &["posthog-elixir"];
+
struct IssueLifecycleInternalEvent<'a, I: NotificationIssue> {
event: &'static str,
notification_id: Uuid,
@@ -26,6 +34,17 @@ pub async fn send_new_fingerprint_event<I: NotificationIssue>(
issue: &I,
output_props: &OutputErrProps,
) -> Result<(), UnhandledError> {
+ if let Some(reason) = skip_fingerprint_embedding_reason(output_props) {
+ metrics::counter!(FINGERPRINT_EMBEDDING_SKIPPED, "reason" => reason).increment(1);
+ debug!(
+ team_id = issue.team_id(),
+ fingerprint = %output_props.fingerprint,
+ reason,
+ "skipping fingerprint embedding request"
+ );
+ return Ok(());
+ }
+
let request = fingerprint_embedding_request(issue, output_props);
let res = send_iter_to_kafka(producer, embedding_worker_topic, &[request])
@@ -38,6 +57,36 @@ pub async fn send_new_fingerprint_event<I: NotificationIssue>(
Ok(())
}
+/// Returns the reason a fingerprint embedding request should be skipped, or
+/// `None` if it should be sent. We don't embed issues grouped by a fingerprint
+/// the user controls — manual fingerprints and custom grouping rules — since
+/// embedding-based similarity grouping doesn't apply to them, nor events from
+/// SDKs in `EMBEDDING_DISABLED_LIBS` (they emit too many issues).
+fn skip_fingerprint_embedding_reason(output_props: &OutputErrProps) -> Option<&'static str> {
+ if output_props
+ .fingerprint_record
+ .iter()
+ .any(|part| matches!(part, FingerprintRecordPart::Manual))
+ {
+ return Some("manual_fingerprint");
+ }
+
+ if output_props
+ .fingerprint_record
+ .iter()
+ .any(|part| matches!(part, FingerprintRecordPart::Custom { .. }))
+ {
+ return Some("custom_grouping_rule");
+ }
+
+ let lib = output_props.other.get("$lib").and_then(Value::as_str);
+ if lib.is_some_and(|lib| EMBEDDING_DISABLED_LIBS.contains(&lib)) {
+ return Some("disabled_sdk");
+ }
+
+ None
+}
+
fn fingerprint_embedding_request<I: NotificationIssue>(
issue: &I,
output_props: &OutputErrProps,
@@ -208,3 +257,71 @@ async fn send_internal_event_with_producer<I: NotificationIssue>(
Err(e) => Err(e.into()),
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn props_with(record: Vec<FingerprintRecordPart>, lib: Option<&str>) -> OutputErrProps {
+ let mut props = OutputErrProps {
+ fingerprint_record: record,
+ ..Default::default()
+ };
+ if let Some(lib) = lib {
+ props
+ .other
+ .insert("$lib".to_string(), Value::String(lib.to_string()));
+ }
+ props
+ }
+
+ #[test]
+ fn sends_embedding_for_automatic_fingerprint() {
+ let props = props_with(
+ vec![FingerprintRecordPart::Exception {
+ id: None,
+ pieces: vec!["boom".to_string()],
+ }],
+ Some("posthog-python"),
+ );
+ assert_eq!(skip_fingerprint_embedding_reason(&props), None);
+ }
+
+ #[test]
+ fn skips_embedding_for_manual_fingerprint() {
+ let props = props_with(vec![FingerprintRecordPart::Manual], Some("posthog-python"));
+ assert_eq!(
+ skip_fingerprint_embedding_reason(&props),
+ Some("manual_fingerprint")
+ );
+ }
+
+ #[test]
+ fn skips_embedding_for_custom_grouping_rule() {
+ let props = props_with(
+ vec![FingerprintRecordPart::Custom {
+ rule_id: Uuid::nil(),
+ }],
+ Some("posthog-python"),
+ );
+ assert_eq!(
+ skip_fingerprint_embedding_reason(&props),
+ Some("custom_grouping_rule")
+ );
+ }
+
+ #[test]
+ fn skips_embedding_for_elixir_sdk() {
+ let props = props_with(
+ vec![FingerprintRecordPart::Exception {
+ id: None,
+ pieces: vec!["boom".to_string()],
+ }],
+ Some("posthog-elixir"),
+ );
+ assert_eq!(
+ skip_fingerprint_embedding_reason(&props),
+ Some("disabled_sdk")
+ );
+ }
+}