Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(txname): Mark all URL transactions as sanitized #2210

Merged
merged 4 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
**Internal**:

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

## 23.5.2

Expand Down
45 changes: 11 additions & 34 deletions relay-general/src/store/transactions/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use crate::types::{
pub struct TransactionNameConfig<'r> {
/// Rules for identifier replacement that were discovered by Sentry's transaction clusterer.
pub rules: &'r [TransactionNameRule],
/// True if URL transactions should be marked as sanitized, even if there are no rules.
pub ready: bool,
}

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

// If the project is marked as 'ready', always set the transaction source to sanitized.
let mut mark_as_sanitized = self.name_config.ready;

if matches!(
event.get_transaction_source(),
&TransactionSource::Url | &TransactionSource::Sanitized
) {
// Normalize transaction names for URLs and Sanitized transaction sources.
// This in addition to renaming rules can catch some high cardinality parts.
scrub_identifiers(&mut event.transaction)?.then(|| {
mark_as_sanitized = true;
});
scrub_identifiers(&mut event.transaction)?;
}

if !self.name_config.rules.is_empty() {
self.apply_transaction_rename_rule(
&mut event.transaction,
event.transaction_info.value_mut(),
)?;

mark_as_sanitized = true;
}

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

process_value(
&mut event,
&mut TransactionsProcessor::new(
TransactionNameConfig {
rules: &[],
ready: true,
},
false,
None,
),
&mut TransactionsProcessor::default(),
ProcessingState::root(),
)
.unwrap();
Expand Down Expand Up @@ -1896,7 +1887,6 @@ mod tests {
&mut TransactionsProcessor::new(
TransactionNameConfig {
rules: rules.as_ref(),
ready: false,
},
false,
None,
Expand Down Expand Up @@ -1962,7 +1952,6 @@ mod tests {
&mut TransactionsProcessor::new(
TransactionNameConfig {
rules: rules.as_ref(),
ready: false,
},
false,
None,
Expand Down Expand Up @@ -2062,7 +2051,6 @@ mod tests {
&mut TransactionsProcessor::new(
TransactionNameConfig {
rules: rules.as_ref(),
ready: false,
},
false,
None,
Expand Down Expand Up @@ -2130,14 +2118,7 @@ mod tests {

process_value(
&mut event,
&mut TransactionsProcessor::new(
TransactionNameConfig {
rules: &[rule],
ready: false,
},
false,
None,
),
&mut TransactionsProcessor::new(TransactionNameConfig { rules: &[rule] }, false, None),
ProcessingState::root(),
)
.unwrap();
Expand Down Expand Up @@ -2364,7 +2345,6 @@ mod tests {
scope: TransactionNameRuleScope::default(),
redaction: RedactionRule::default(),
}],
ready: false,
},
false,
None,
Expand Down Expand Up @@ -2412,7 +2392,6 @@ mod tests {
scope: TransactionNameRuleScope::default(),
redaction: RedactionRule::default(),
}],
ready: false,
},
false,
None,
Expand Down Expand Up @@ -2894,7 +2873,6 @@ mod tests {
scope: TransactionNameRuleScope::default(),
redaction: RedactionRule::default(),
}],
..Default::default()
},
true,
None,
Expand Down Expand Up @@ -2995,7 +2973,6 @@ mod tests {
scope: TransactionNameRuleScope::default(),
redaction: RedactionRule::default(),
}],
..Default::default()
},
true,
Some(&Vec::from([SpanDescriptionRule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ expression: event
"type": "transaction",
"transaction": "/remains/rule-target/whatever",
"transaction_info": {
"source": "url"
"source": "sanitized"
},
"timestamp": 1619420400.0,
"start_timestamp": 1619420341.0,
Expand Down
2 changes: 0 additions & 2 deletions relay-server/src/actors/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,6 @@ impl EnvelopeProcessorService {
normalize_user_agent: Some(true),
transaction_name_config: TransactionNameConfig {
rules: &state.project_state.config.tx_name_rules,
ready: state.project_state.config.tx_name_ready,
},
device_class_synthesis_config: state
.project_state
Expand Down Expand Up @@ -3716,7 +3715,6 @@ mod tests {
substitution: "*".to_owned(),
},
}],
ready: false,
},
..Default::default()
};
Expand Down