From 00e540bbf17e1dd16ba9976df402e6002cc56700 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 6 Jun 2024 11:13:44 -0400 Subject: [PATCH 1/3] feat(spans): Group function spans --- .../src/normalize/span/description/mod.rs | 23 +++++++++++++++++-- relay-event-normalization/src/regexes.rs | 12 ++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/relay-event-normalization/src/normalize/span/description/mod.rs b/relay-event-normalization/src/normalize/span/description/mod.rs index f3d2eb2623..c9c1302177 100644 --- a/relay-event-normalization/src/normalize/span/description/mod.rs +++ b/relay-event-normalization/src/normalize/span/description/mod.rs @@ -13,8 +13,8 @@ use std::path::Path; use url::{Host, Url}; use crate::regexes::{ - DB_SQL_TRANSACTION_CORE_DATA_REGEX, DB_SUPABASE_REGEX, REDIS_COMMAND_REGEX, - RESOURCE_NORMALIZER_REGEX, + DB_SQL_TRANSACTION_CORE_DATA_REGEX, DB_SUPABASE_REGEX, FUNCTION_NORMALIZER_REGEX, + REDIS_COMMAND_REGEX, RESOURCE_NORMALIZER_REGEX, }; use crate::span::description::resource::COMMON_PATH_SEGMENTS; use crate::span::tag_extraction::HTTP_METHOD_EXTRACTOR_REGEX; @@ -135,6 +135,7 @@ pub(crate) fn scrub_span_description( Some(description.to_owned()) } ("file", _) => scrub_file(description), + ("function", _) => scrub_function(description), _ => None, }); (scrubbed_description, parsed_sql) @@ -521,6 +522,10 @@ fn scrub_resource_file_extension(mut extension: &str) -> &str { extension } +fn scrub_function(string: &str) -> Option { + Some(FUNCTION_NORMALIZER_REGEX.replace_all(string, "*").into()) +} + #[cfg(test)] mod tests { use relay_protocol::Annotated; @@ -1072,6 +1077,20 @@ mod tests { span_description_test!(db_prisma, "User find", "db.sql.prisma", "User find"); + span_description_test!( + function_python, + "sentry.event_manager.assign_event_to_group", + "function", + "sentry.event_manager.assign_event_to_group" + ); + + span_description_test!( + function_rust, + "symbolicator_native::symbolication::symbolicate::symbolicate", + "function", + "symbolicator_native::symbolication::symbolicate::symbolicate" + ); + #[test] fn informed_sql_parser() { let json = r#" diff --git a/relay-event-normalization/src/regexes.rs b/relay-event-normalization/src/regexes.rs index b273f1ef07..86b459e9f1 100644 --- a/relay-event-normalization/src/regexes.rs +++ b/relay-event-normalization/src/regexes.rs @@ -95,3 +95,15 @@ pub static DB_SUPABASE_REGEX: Lazy = Lazy::new(|| { ) .unwrap() }); + +pub static FUNCTION_NORMALIZER_REGEX: Lazy = Lazy::new(|| { + Regex::new( + r"(?xi) + # UUIDs. + (?P[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}) | + # Hexadecimal strings with more than 5 digits. + (?P[a-f0-9]{5}[a-f0-9]+) + ", + ) + .unwrap() +}); From 9d168174b397d537885b64317e83d2e8c79c8b19 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Fri, 7 Jun 2024 11:39:16 -0400 Subject: [PATCH 2/3] Add tests with scrubbing involved --- .../src/normalize/span/description/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/relay-event-normalization/src/normalize/span/description/mod.rs b/relay-event-normalization/src/normalize/span/description/mod.rs index c9c1302177..224f383dcc 100644 --- a/relay-event-normalization/src/normalize/span/description/mod.rs +++ b/relay-event-normalization/src/normalize/span/description/mod.rs @@ -1091,6 +1091,20 @@ mod tests { "symbolicator_native::symbolication::symbolicate::symbolicate" ); + span_description_test!( + function_with_hex, + "symbolicator_native::symbolication::symbolicate::deadbeef", + "function", + "symbolicator_native::symbolication::symbolicate::*" + ); + + span_description_test!( + function_with_uuid, + "symbolicator_native::symbolication::fb37f08422034ee985e9fc553ef27e6e::symbolicate", + "function", + "symbolicator_native::symbolication::*::symbolicate" + ); + #[test] fn informed_sql_parser() { let json = r#" From 8da73d1200677e0b130858912ad52cba8ade1672 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Fri, 7 Jun 2024 11:42:51 -0400 Subject: [PATCH 3/3] Add a CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15c9b13791..a38df7e3ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Send `attachment` data inline when possible. ([#3654](https://github.com/getsentry/relay/pull/3654)) - Drops support for transaction metrics extraction versions < 3. ([#3672](https://github.com/getsentry/relay/pull/3672)) - Move partitioning into the `Aggregator` and add a new `Partition` bucket shift mode. ([#3661](https://github.com/getsentry/relay/pull/3661)) +- Calculate group hash for function spans. ([#3697](https://github.com/getsentry/relay/pull/3697)) ## 24.5.0