Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- Extend GPU context with data for Unreal Engine crash reports. ([#3144](https://github.com/getsentry/relay/pull/3144))
- Parametrize transaction in dynamic sampling context. ([#3141](https://github.com/getsentry/relay/pull/3141))
- Parse & scrub span description for supabase. ([#3153](https://github.com/getsentry/relay/pull/3153))
- Parse & scrub span description for supabase. ([#3153](https://github.com/getsentry/relay/pull/3153), [#3156](https://github.com/getsentry/relay/pull/3156))

**Bug Fixes**:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ pub(crate) fn scrub_span_description(
// The description will only contain the entity queried and
// the query type ("User find" for example).
Some(description.to_owned())
} else if span_origin == Some("auto.db.supabase") {
} else if span_origin == Some("auto.db.supabase")
&& description.starts_with("from(")
{
// The description only contains the table name, e.g. `"from(users)`.
// In the future, we might want to parse `data.query` as well.
// See https://github.com/supabase-community/sentry-integration-js/blob/master/index.js#L259
Expand Down Expand Up @@ -148,10 +150,7 @@ fn scrub_core_data(string: &str) -> Option<String> {
}

fn scrub_supabase(string: &str) -> Option<String> {
match DB_SUPABASE_REGEX.replace_all(string, "{%s}") {
Cow::Owned(scrubbed) => Some(scrubbed),
Cow::Borrowed(_) => None,
}
Some(DB_SUPABASE_REGEX.replace_all(string, "{%s}").into())
}

fn scrub_http(string: &str) -> Option<String> {
Expand Down
36 changes: 31 additions & 5 deletions relay-event-normalization/src/normalize/span/tag_extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,10 +1435,9 @@ LIMIT 1
);
}

#[test]
fn supabase() {
fn extract_tags_supabase(description: impl Into<String>) -> BTreeMap<SpanTagKey, String> {
let json = r#"{
"description": "from(my_table00)",
"description": "from(my_table)",
"op": "db.select",
"origin": "auto.db.supabase",
"data": {
Expand All @@ -1449,12 +1448,13 @@ LIMIT 1
}
}"#;

let span = Annotated::<Span>::from_json(json)
let mut span = Annotated::<Span>::from_json(json)
.unwrap()
.into_value()
.unwrap();
span.description.set_value(Some(description.into()));

let tags = extract_tags(
extract_tags(
&span,
&Config {
max_tag_value_size: 200,
Expand All @@ -1463,7 +1463,25 @@ LIMIT 1
None,
false,
None,
)
}

#[test]
fn supabase() {
let tags = extract_tags_supabase("from(mytable)");
assert_eq!(
tags.get(&SpanTagKey::Description).map(String::as_str),
Some("from(mytable)")
);
assert_eq!(
tags.get(&SpanTagKey::Domain).map(String::as_str),
Some("mytable")
);
}

#[test]
fn supabase_with_identifiers() {
let tags = extract_tags_supabase("from(my_table00)");

assert_eq!(
tags.get(&SpanTagKey::Description).map(String::as_str),
Expand All @@ -1474,4 +1492,12 @@ LIMIT 1
Some("my_table{%s}")
);
}

#[test]
fn supabase_unsupported() {
let tags = extract_tags_supabase("something else");

assert_eq!(tags.get(&SpanTagKey::Description), None);
assert_eq!(tags.get(&SpanTagKey::Domain), None);
}
}