Skip to content

Commit

Permalink
feat(spans): Group all browser resources together (#2676)
Browse files Browse the repository at this point in the history
We want to filter out resource spans from browser extensions, so scrub
their description to `browser-extension://*` such that they all end up
in the same group.

ref: getsentry/sentry#58723
  • Loading branch information
jjbayer committed Oct 31, 2023
1 parent dd523d0 commit 70f0860
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
11 changes: 3 additions & 8 deletions relay-event-normalization/src/normalize/span/description/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,8 @@ fn scrub_resource(string: &str) -> Option<String> {
Some((ty, _data)) => format!("data:{ty}"),
None => "data:*/*".to_owned(),
},
"chrome-extension" => {
let path = scrub_resource_path(url.path());
format!("chrome-extension://*{path}")
}
"moz-extension" => {
let path = scrub_resource_path(url.path());
format!("moz-extension://*{path}")
"chrome-extension" | "moz-extension" | "ms-browser-extension" => {
return Some("browser-extension://*".to_owned());
}
scheme => {
let segments = url.path_segments();
Expand Down Expand Up @@ -545,7 +540,7 @@ mod tests {
chrome_extension,
"chrome-extension://begnopegbbhjeeiganiajffnalhlkkjb/img/assets/icon-10k.svg",
"resource.other",
"chrome-extension://*/img/assets/icon-*k.svg"
"browser-extension://*"
);

span_description_test!(
Expand Down
10 changes: 10 additions & 0 deletions relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ mod tests {
"status": "ok",
"data": {}
},
{
"description": "chrome-extension://begnopegbbhjeeiganiajffnalhlkkjb/img/assets/icon-10k.svg",
"op": "resource.script",
"parent_span_id": "8f5a2b8768cafb4e",
"span_id": "bb7af8b99e95af5f",
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976302.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81",
"status": "ok"
},
{
"description": "http://domain/static/myscript-v1.9.23.js",
"op": "resource.script",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,51 @@ expression: metrics
"transaction.op": "myop",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
name: "d:spans/exclusive_time@millisecond",
value: Distribution(
[
2000.0,
],
),
tags: {
"environment": "fake_environment",
"http.status_code": "500",
"span.category": "resource",
"span.description": "browser-extension://*",
"span.domain": "*",
"span.group": "3e92c536f98104b2",
"span.op": "resource.script",
"span.status": "ok",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
"transaction.op": "myop",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
name: "d:spans/exclusive_time_light@millisecond",
value: Distribution(
[
2000.0,
],
),
tags: {
"environment": "fake_environment",
"http.status_code": "500",
"span.category": "resource",
"span.description": "browser-extension://*",
"span.domain": "*",
"span.group": "3e92c536f98104b2",
"span.op": "resource.script",
"span.status": "ok",
"transaction.method": "POST",
"transaction.op": "myop",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
Expand Down

0 comments on commit 70f0860

Please sign in to comment.