Skip to content

Commit c057e37

Browse files
feat(txname): Mark all URL transactions as sanitized (#2210)
In #2139, we transitioned to marking all URL transactions as "sanitized" once sentry provides the "ready" flag. However, this results in a bad onboarding experience for new projects because they still see `<< unparameterized >>` for the first ~10 hours. This PR removes the "ready" condition, such that _all_ transactions with source URL will now get their transaction name added as a metric tag. Since we were already doing this for all but the newest projects, this should not add much cardinality after all. But we have to keep an eye on the cardinality limiter in the first few hours / days after deploying this. Fixes #2186 --------- Co-authored-by: Iker Barriocanal <[email protected]>
1 parent 94c2a3a commit c057e37

File tree

4 files changed

+13
-37
lines changed

4 files changed

+13
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
**Internal**:
1818

1919
- Extract app identifier from app context for profiles. ([#2172](https://github.com/getsentry/relay/pull/2172))
20+
- Mark all URL transactions as sanitized after applying rules. ([#2210](https://github.com/getsentry/relay/pull/2210))
2021

2122
## 23.5.2
2223

relay-general/src/store/transactions/processor.rs

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ use crate::types::{
2424
pub struct TransactionNameConfig<'r> {
2525
/// Rules for identifier replacement that were discovered by Sentry's transaction clusterer.
2626
pub rules: &'r [TransactionNameRule],
27-
/// True if URL transactions should be marked as sanitized, even if there are no rules.
28-
pub ready: bool,
2927
}
3028

3129
/// Rejects transactions based on required fields.
@@ -471,30 +469,30 @@ impl Processor for TransactionsProcessor<'_> {
471469
.set_value(Some("<unlabeled transaction>".to_owned()))
472470
}
473471

474-
// If the project is marked as 'ready', always set the transaction source to sanitized.
475-
let mut mark_as_sanitized = self.name_config.ready;
476-
477472
if matches!(
478473
event.get_transaction_source(),
479474
&TransactionSource::Url | &TransactionSource::Sanitized
480475
) {
481476
// Normalize transaction names for URLs and Sanitized transaction sources.
482477
// This in addition to renaming rules can catch some high cardinality parts.
483-
scrub_identifiers(&mut event.transaction)?.then(|| {
484-
mark_as_sanitized = true;
485-
});
478+
scrub_identifiers(&mut event.transaction)?;
486479
}
487480

488481
if !self.name_config.rules.is_empty() {
489482
self.apply_transaction_rename_rule(
490483
&mut event.transaction,
491484
event.transaction_info.value_mut(),
492485
)?;
493-
494-
mark_as_sanitized = true;
495486
}
496487

497-
if mark_as_sanitized && matches!(event.get_transaction_source(), &TransactionSource::Url) {
488+
if matches!(event.get_transaction_source(), &TransactionSource::Url) {
489+
// Always mark URL transactions as sanitized, even if no modification were made by
490+
// clusterer rules or regex matchers. This has the consequence that the transaction name
491+
// is always extracted as a tag on transaction metrics.
492+
// Instead of changing the source to "sanitized", we could have changed metrics extraction
493+
// to also extract the transaction name for URL transactions. But this is the safer way,
494+
// because the product currently uses queries that assume that `source:url` is equivalent
495+
// to `transaction:<< unparameterized >>`.
498496
event
499497
.transaction_info
500498
.get_or_insert_with(Default::default)
@@ -1808,14 +1806,7 @@ mod tests {
18081806

18091807
process_value(
18101808
&mut event,
1811-
&mut TransactionsProcessor::new(
1812-
TransactionNameConfig {
1813-
rules: &[],
1814-
ready: true,
1815-
},
1816-
false,
1817-
None,
1818-
),
1809+
&mut TransactionsProcessor::default(),
18191810
ProcessingState::root(),
18201811
)
18211812
.unwrap();
@@ -1896,7 +1887,6 @@ mod tests {
18961887
&mut TransactionsProcessor::new(
18971888
TransactionNameConfig {
18981889
rules: rules.as_ref(),
1899-
ready: false,
19001890
},
19011891
false,
19021892
None,
@@ -1962,7 +1952,6 @@ mod tests {
19621952
&mut TransactionsProcessor::new(
19631953
TransactionNameConfig {
19641954
rules: rules.as_ref(),
1965-
ready: false,
19661955
},
19671956
false,
19681957
None,
@@ -2062,7 +2051,6 @@ mod tests {
20622051
&mut TransactionsProcessor::new(
20632052
TransactionNameConfig {
20642053
rules: rules.as_ref(),
2065-
ready: false,
20662054
},
20672055
false,
20682056
None,
@@ -2130,14 +2118,7 @@ mod tests {
21302118

21312119
process_value(
21322120
&mut event,
2133-
&mut TransactionsProcessor::new(
2134-
TransactionNameConfig {
2135-
rules: &[rule],
2136-
ready: false,
2137-
},
2138-
false,
2139-
None,
2140-
),
2121+
&mut TransactionsProcessor::new(TransactionNameConfig { rules: &[rule] }, false, None),
21412122
ProcessingState::root(),
21422123
)
21432124
.unwrap();
@@ -2364,7 +2345,6 @@ mod tests {
23642345
scope: TransactionNameRuleScope::default(),
23652346
redaction: RedactionRule::default(),
23662347
}],
2367-
ready: false,
23682348
},
23692349
false,
23702350
None,
@@ -2412,7 +2392,6 @@ mod tests {
24122392
scope: TransactionNameRuleScope::default(),
24132393
redaction: RedactionRule::default(),
24142394
}],
2415-
ready: false,
24162395
},
24172396
false,
24182397
None,
@@ -2894,7 +2873,6 @@ mod tests {
28942873
scope: TransactionNameRuleScope::default(),
28952874
redaction: RedactionRule::default(),
28962875
}],
2897-
..Default::default()
28982876
},
28992877
true,
29002878
None,
@@ -2995,7 +2973,6 @@ mod tests {
29952973
scope: TransactionNameRuleScope::default(),
29962974
redaction: RedactionRule::default(),
29972975
}],
2998-
..Default::default()
29992976
},
30002977
true,
30012978
Some(&Vec::from([SpanDescriptionRule {

relay-general/src/store/transactions/snapshots/relay_general__store__transactions__processor__tests__no_sanitized_if_no_rules.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ expression: event
66
"type": "transaction",
77
"transaction": "/remains/rule-target/whatever",
88
"transaction_info": {
9-
"source": "url"
9+
"source": "sanitized"
1010
},
1111
"timestamp": 1619420400.0,
1212
"start_timestamp": 1619420341.0,

relay-server/src/actors/processor.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,6 @@ impl EnvelopeProcessorService {
23572357
normalize_user_agent: Some(true),
23582358
transaction_name_config: TransactionNameConfig {
23592359
rules: &state.project_state.config.tx_name_rules,
2360-
ready: state.project_state.config.tx_name_ready,
23612360
},
23622361
device_class_synthesis_config: state
23632362
.project_state
@@ -3716,7 +3715,6 @@ mod tests {
37163715
substitution: "*".to_owned(),
37173716
},
37183717
}],
3719-
ready: false,
37203718
},
37213719
..Default::default()
37223720
};

0 commit comments

Comments
 (0)