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

fix(py): Respect the renormalize flag #1548

Merged
merged 4 commits into from
Oct 25, 2022
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
6 changes: 6 additions & 0 deletions py/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Changelog

## Unreleased

- Restore correct behavior when `is_renormalize` is specified on `normalize_event`. ([#1548](https://github.com/getsentry/relay/pull/1548))

## 0.8.14

**Warning:** This release contains a regression. Please update to a more recent version.

- Add `transaction_info` to event payloads, including the transaction's source and internal original transaction name. ([#1330](https://github.com/getsentry/relay/pull/1330))
- Add user-agent parsing to replays processor. ([#1420](https://github.com/getsentry/relay/pull/1420))
- `convert_datascrubbing_config` will now return an error string when conversion fails on big regexes. ([#1474](https://github.com/getsentry/relay/pull/1474))
Expand Down
13 changes: 10 additions & 3 deletions relay-cabi/src/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,17 @@ pub unsafe extern "C" fn relay_store_normalizer_normalize_event(
) -> RelayStr {
let processor = normalizer as *mut StoreProcessor;
let mut event = Annotated::<Event>::from_json((*event).as_str())?;
let config = (*processor).config();
let light_normalization_config = LightNormalizationConfig {
normalize_user_agent: (*processor).config().normalize_user_agent,
is_renormalize: (*processor).config().is_renormalize.unwrap_or(false),
..Default::default()
client_ip: config.client_ip.as_ref(),
user_agent: config.user_agent.as_deref(),
received_at: config.received_at,
max_secs_in_past: config.max_secs_in_past,
max_secs_in_future: config.max_secs_in_future,
measurements_config: None, // only supported in relay
breakdowns_config: None, // only supported in relay
normalize_user_agent: config.normalize_user_agent,
is_renormalize: config.is_renormalize.unwrap_or(false),
};
light_normalize_event(&mut event, &light_normalization_config)?;
process_value(&mut event, &mut *processor, ProcessingState::root())?;
Expand Down
58 changes: 47 additions & 11 deletions relay-general/src/store/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,18 +675,17 @@ pub fn light_normalize_event(
event: &mut Annotated<Event>,
config: &LightNormalizationConfig,
) -> ProcessingResult {
if config.is_renormalize {
return Ok(());
}

event.apply(|event, meta| {
if !config.is_renormalize {
// Validate and normalize transaction
// (internally noops for non-transaction events).
// TODO: Parts of this processor should probably be a filter so we
// can revert some changes to ProcessingAction
transactions::TransactionsProcessor.process_event(
event,
meta,
ProcessingState::root(),
)?;
}
// Validate and normalize transaction
// (internally noops for non-transaction events).
// TODO: Parts of this processor should probably be a filter so we
// can revert some changes to ProcessingAction
transactions::TransactionsProcessor.process_event(event, meta, ProcessingState::root())?;

// Check for required and non-empty values
schema::SchemaProcessor.process_event(event, meta, ProcessingState::root())?;

Expand Down Expand Up @@ -983,6 +982,7 @@ impl<'a> Processor for NormalizeProcessor<'a> {
#[cfg(test)]
mod tests {
use chrono::TimeZone;
use insta::assert_debug_snapshot;
use serde_json::json;
use similar_asserts::assert_eq;

Expand Down Expand Up @@ -2287,4 +2287,40 @@ mod tests {
assert!(res.is_err(), "{:?}", span);
}
}

#[test]
fn test_light_normalization_respects_is_renormalize() {
let mut event = Annotated::<Event>::from_json(
r###"
{
"type": "default",
"tags": [["environment", "some_environment"]]
}
"###,
)
.unwrap();

let result = light_normalize_event(
&mut event,
&LightNormalizationConfig {
is_renormalize: true,
..Default::default()
},
);

assert!(result.is_ok());

assert_debug_snapshot!(event.value().unwrap().tags, @r###"
Tags(
PairList(
[
TagEntry(
"environment",
"some_environment",
),
],
),
)
"###);
}
}