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(spans): Collect exclusive time for all spans #3268

Merged
merged 11 commits into from
Mar 18, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Filter null values from metrics summary tags. ([#3204](https://github.com/getsentry/relay/pull/3204))
- Emit a usage metric for every span seen. ([#3209](https://github.com/getsentry/relay/pull/3209))
- Add namespace for profile metrics. ([#3229](https://github.com/getsentry/relay/pull/3229))
- Collect exclusive time for all spans. ([#3268](https://github.com/getsentry/relay/pull/3268))
- Add segment_id to the profile. ([#3265](https://github.com/getsentry/relay/pull/3265))

## 24.2.0
Expand Down
31 changes: 15 additions & 16 deletions relay-dynamic-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
| is_http.clone())
& duration_condition.clone();

let know_modules_condition =
(is_db.clone() | is_resource.clone() | is_mobile.clone() | is_http.clone())
& duration_condition.clone();

[
MetricSpec {
category: DataCategory::Span,
Expand All @@ -142,17 +146,18 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
category: DataCategory::Span,
mri: "d:spans/exclusive_time@millisecond".into(),
field: Some("span.exclusive_time".into()),
condition: Some(
(is_db.clone() | is_resource.clone() | is_mobile.clone() | is_http.clone())
& duration_condition.clone(),
),
condition: None,
Copy link
Member

Choose a reason for hiding this comment

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

Should we still apply duration_condition here? Asking because even span_per_op and spans_per_segment apply the duration condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we'd want to apply the duration condition here. We want to track absolutely all spans here and the condition was mainly created for a mobile specific use case.

tags: vec![
// Common tags:
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(),
Tag::with_key("environment")
.from_field("span.sentry_tags.environment")
.when(
is_db.clone() | is_resource.clone() | is_mobile.clone() | is_http.clone(),
),
.always(),
Tag::with_key("span.op")
.from_field("span.sentry_tags.op")
.always(),
Tag::with_key("transaction.method")
.from_field("span.sentry_tags.transaction.method")
.when(is_db.clone() | is_mobile.clone() | is_http.clone()), // groups by method + txn, e.g. `GET /users`
Expand All @@ -161,22 +166,16 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
.when(is_db.clone()),
Tag::with_key("span.category")
.from_field("span.sentry_tags.category")
.always(),
.when(know_modules_condition.clone()),
Tag::with_key("span.description")
.from_field("span.sentry_tags.description")
.always(),
.when(know_modules_condition.clone()),
Tag::with_key("span.domain")
.from_field("span.sentry_tags.domain")
.when(is_db.clone() | is_resource.clone() | is_http.clone()),
Tag::with_key("span.group")
.from_field("span.sentry_tags.group")
.always(),
Tag::with_key("span.op")
.from_field("span.sentry_tags.op")
.always(),
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(),
.when(know_modules_condition.clone()),
// Mobile:
Tag::with_key("transaction.op")
.from_field("span.sentry_tags.transaction.op")
Expand Down
8 changes: 4 additions & 4 deletions relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ mod tests {
let metrics = extract_span_metrics_mobile("app.start.cold", 181000.0);
assert_eq!(
metrics.iter().map(|m| &m.name).collect::<Vec<_>>(),
vec!["c:spans/usage@none"]
vec!["c:spans/usage@none", "d:spans/exclusive_time@millisecond"]
);
}

Expand All @@ -1323,7 +1323,7 @@ mod tests {
let metrics = extract_span_metrics_mobile("app.start.warm", 181000.0);
assert_eq!(
metrics.iter().map(|m| &m.name).collect::<Vec<_>>(),
vec!["c:spans/usage@none"]
vec!["c:spans/usage@none", "d:spans/exclusive_time@millisecond"]
);
}

Expand All @@ -1347,7 +1347,7 @@ mod tests {
let metrics = extract_span_metrics_mobile("ui.load.initial_display", 181000.0);
assert_eq!(
metrics.iter().map(|m| &m.name).collect::<Vec<_>>(),
vec!["c:spans/usage@none"]
vec!["c:spans/usage@none", "d:spans/exclusive_time@millisecond"]
);
}

Expand All @@ -1371,7 +1371,7 @@ mod tests {
let metrics = extract_span_metrics_mobile("ui.load.full_display", 181000.0);
assert_eq!(
metrics.iter().map(|m| &m.name).collect::<Vec<_>>(),
vec!["c:spans/usage@none"]
vec!["c:spans/usage@none", "d:spans/exclusive_time@millisecond"]
);
}

Expand Down
Loading
Loading