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

feat(perf): Extract span.status_code tag for HTTP spans #3245

Merged
merged 4 commits into from
Mar 12, 2024
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
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the tag in d:spans/exclusive_time_light@millisecond too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure what you mean—from what I can see I added the tag to that metric, did I do something wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tag is added to two metrics: d:spans/exclusive_time@millisecond and d:spans/exclusive_time_light@millisecond. Do we need the tag in both metrics, or just one of the two metrics is good enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see! I need it for both, since the light metric is only used on the landing page, and the regular one is used on the domain landing pages, where we have to break down by transaction

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! :shipit:

.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
Loading