: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
perf(error-tracking): defer suppression/assignment rule serialization (#67404)
Catalin Irimiefe4f0ac0a7cd
diff --git a/rust/cymbal/src/modes/processing/rules/assignment.rs b/rust/cymbal/src/modes/processing/rules/assignment.rsindex ce98428860f5..86c0ca72c865 100644--- a/rust/cymbal/src/modes/processing/rules/assignment.rs+++ b/rust/cymbal/src/modes/processing/rules/assignment.rs@@ -221,6 +221,22 @@ pub async fn try_assignment_rules(exception_properties: &OutputErrProps,) -> Result<Option<NewAssignment>, UnhandledError> {let timing = common_metrics::timing_guard(ASSIGNMENT_RULES_PROCESSING_TIME, &[]);++ let mut rules = team_manager+ .get_assignment_rules(&mut *con, issue.team_id)+ .await?;++ metrics::counter!(ASSIGNMENT_RULES_FOUND).increment(rules.len() as u64);++ // Most teams have no assignment rules; skip serializing the issue and the+ // (expensive) event properties unless a rule might actually match.+ if rules.is_empty() {+ timing.label("outcome", "no_match").fin();+ return Ok(None);+ }++ rules.sort_unstable_by_key(|r| r.order_key);+#[derive(Debug, Clone, Serialize, Deserialize)]struct IssueJson {status: String,@@ -236,14 +252,6 @@ pub async fn try_assignment_rules(let props_json = serde_json::to_value(exception_properties)?;- let mut rules = team_manager- .get_assignment_rules(&mut *con, issue.team_id)- .await?;-- metrics::counter!(ASSIGNMENT_RULES_FOUND).increment(rules.len() as u64);-- rules.sort_unstable_by_key(|r| r.order_key);-for rule in rules {match rule.try_match(&issue_json, &props_json) {Ok(None) => continue,diff --git a/rust/cymbal/src/modes/processing/stages/linking/rule_suppression.rs b/rust/cymbal/src/modes/processing/stages/linking/rule_suppression.rsindex 79b7c1861422..c7481b10bae6 100644--- a/rust/cymbal/src/modes/processing/stages/linking/rule_suppression.rs+++ b/rust/cymbal/src/modes/processing/stages/linking/rule_suppression.rs@@ -25,11 +25,6 @@ impl ValueOperator for RuleSuppression {}async fn execute_value(&self, input: Self::Item, ctx: LinkingStage) -> OperatorResult<Self> {- let props_json = match serde_json::to_value(&input) {- Ok(v) => v,- Err(_) => return Ok(Ok(input)),- };-let mut rules = ctx.app_context.team_manager@@ -42,6 +37,12 @@ impl ValueOperator for RuleSuppression {rules.sort_unstable_by_key(|r| r.order_key);+ // Only serialize the event once we know the team has suppression rules.+ let props_json = match serde_json::to_value(&input) {+ Ok(v) => v,+ Err(_) => return Ok(Ok(input)),+ };+for rule in rules {match rule.should_suppress(&props_json, &input.uuid) {Ok(false) => continue,