Skip to content

Commit

Permalink
feat(perf): Extract span.status_code tag for HTTP spans (#3245)
Browse files Browse the repository at this point in the history
We need this to do status code breakdowns for the HTTP module.
  • Loading branch information
gggritso authored Mar 12, 2024
1 parent 6bd48f6 commit f56e54b
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- Enable HTTP compression for all APIs. ([#3233](https://github.com/getsentry/relay/pull/3233))
- Add `process.load` span to ingested mobile span ops. ([#3227](https://github.com/getsentry/relay/pull/3227))
- Enforce rate limits for standalone spans. ([#3238](https://github.com/getsentry/relay/pull/3238))

- Extract `span.status_code` tag for HTTP spans. ([#3245](https://github.com/getsentry/relay/pull/3245))

**Bug Fixes**:

Expand Down
8 changes: 8 additions & 0 deletions relay-dynamic-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
Tag::with_key("resource.render_blocking_status")
.from_field("span.sentry_tags.resource.render_blocking_status")
.when(is_resource.clone()),
// HTTP module:
Tag::with_key("span.status_code")
.from_field("span.sentry_tags.status_code")
.when(is_http.clone()),
],
},
MetricSpec {
Expand Down Expand Up @@ -260,6 +264,10 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
Tag::with_key("resource.render_blocking_status")
.from_field("span.sentry_tags.resource.render_blocking_status")
.when(is_resource.clone()),
// HTTP module:
Tag::with_key("span.status_code")
.from_field("span.sentry_tags.status_code")
.when(is_http.clone()),
],
},
MetricSpec {
Expand Down
13 changes: 13 additions & 0 deletions relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ mod tests {
"http.method": "GET"
}
},
{
"description": "GET /hi/this/is/just/the/path",
"op": "http.client",
"parent_span_id": "8f5a2b8768cafb4e",
"span_id": "bd429c44b67a3eb4",
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976302.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81",
"data": {
"http.method": "GET",
"status_code": "500"
}
},
{
"description": "POST http://127.0.0.1:1234/api/hi",
"op": "http.client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,56 @@ expression: metrics
"span.op": "http.client",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
name: "d:spans/exclusive_time@millisecond",
value: Distribution(
[
2000.0,
],
),
tags: {
"environment": "fake_environment",
"span.category": "http",
"span.description": "GET *",
"span.group": "37e3d9fab1ae9162",
"span.op": "http.client",
"span.status_code": "500",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
name: "d:spans/exclusive_time_light@millisecond",
value: Distribution(
[
2000.0,
],
),
tags: {
"environment": "fake_environment",
"span.category": "http",
"span.description": "GET *",
"span.group": "37e3d9fab1ae9162",
"span.op": "http.client",
"span.status_code": "500",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
name: "c:spans/count_per_op@none",
value: Counter(
1.0,
),
tags: {
"span.category": "http",
"span.op": "http.client",
},
},
Bucket {
timestamp: UnixTimestamp(1597976302),
width: 0,
Expand All @@ -228,6 +278,7 @@ expression: metrics
"span.description": "POST http://127.0.0.1:1234",
"span.group": "464fe695f9cf639c",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -247,6 +298,7 @@ expression: metrics
"span.description": "POST http://127.0.0.1:1234",
"span.group": "464fe695f9cf639c",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -277,6 +329,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -297,6 +350,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -327,6 +381,7 @@ expression: metrics
"span.domain": "targetdomain.tld:1234",
"span.group": "72ab88b506cb04b2",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -347,6 +402,7 @@ expression: metrics
"span.domain": "targetdomain.tld:1234",
"span.group": "72ab88b506cb04b2",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -377,6 +433,7 @@ expression: metrics
"span.domain": "targetdomain:1234",
"span.group": "c8e531abe96ff360",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -397,6 +454,7 @@ expression: metrics
"span.domain": "targetdomain:1234",
"span.group": "c8e531abe96ff360",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -427,6 +485,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -447,6 +506,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -477,6 +537,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -497,6 +558,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -1726,6 +1788,7 @@ expression: metrics
"span.description": "POST http://127.0.0.1:1234",
"span.group": "464fe695f9cf639c",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -1745,6 +1808,7 @@ expression: metrics
"span.description": "POST http://127.0.0.1:1234",
"span.group": "464fe695f9cf639c",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -1775,6 +1839,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -1795,6 +1860,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -1825,6 +1891,7 @@ expression: metrics
"span.domain": "targetdomain.tld:1234",
"span.group": "72ab88b506cb04b2",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -1845,6 +1912,7 @@ expression: metrics
"span.domain": "targetdomain.tld:1234",
"span.group": "72ab88b506cb04b2",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -1875,6 +1943,7 @@ expression: metrics
"span.domain": "targetdomain:1234",
"span.group": "c8e531abe96ff360",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -1895,6 +1964,7 @@ expression: metrics
"span.domain": "targetdomain:1234",
"span.group": "c8e531abe96ff360",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -1925,6 +1995,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -1945,6 +2016,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down Expand Up @@ -1975,6 +2047,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
"transaction": "gEt /api/:version/users/",
"transaction.method": "POST",
},
Expand All @@ -1995,6 +2068,7 @@ expression: metrics
"span.domain": "*.domain.tld:1234",
"span.group": "86818d1c74ecfc66",
"span.op": "http.client",
"span.status_code": "200",
},
},
Bucket {
Expand Down

0 comments on commit f56e54b

Please sign in to comment.