Skip to content

Commit

Permalink
feat(spans): Collect duration for all spans (#3322)
Browse files Browse the repository at this point in the history
  • Loading branch information
phacops authored Mar 26, 2024
1 parent 65b38f2 commit a1db65e
Show file tree
Hide file tree
Showing 7 changed files with 1,662 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Scrub transactions before enforcing quotas. ([#3248](https://github.com/getsentry/relay/pull/3248))
- Kafka topic config supports default topic names as keys. ([#3282](https://github.com/getsentry/relay/pull/3282))
- Set all span tags on the transaction span. ([#3310](https://github.com/getsentry/relay/pull/3310))
- Collect duration for all spans. ([#3322](https://github.com/getsentry/relay/pull/3322))
- Add `project_id` as part of the span Kafka message headers. ([#3320](https://github.com/getsentry/relay/pull/3320))
- Stop producing to sessions topic, the feature is now fully migrated to metrics. ([#3271](https://github.com/getsentry/relay/pull/3271))

Expand Down
38 changes: 21 additions & 17 deletions relay-dynamic-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
Number::from_f64(MAX_DURATION_MOBILE_MS).unwrap_or(0.into()),
);

let app_start_condition = RuleCondition::glob("span.op", "app.start.*")
let app_start_condition = duration_condition.clone()
& RuleCondition::glob("span.op", "app.start.*")
& RuleCondition::eq("span.description", APP_START_ROOT_SPAN_DESCRIPTIONS);

// `exclusive_time_light` is the metric with the most lenient condition.
Expand Down Expand Up @@ -400,37 +401,40 @@ fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
category: DataCategory::Span,
mri: "d:spans/duration@millisecond".into(),
field: Some("span.duration".into()),
condition: Some(
duration_condition.clone() & is_mobile.clone() & app_start_condition.clone(),
),
condition: None,
tags: vec![
// All modules:
Tag::with_key("environment")
.from_field("span.sentry_tags.environment")
.always(),
Tag::with_key("span.op")
.from_field("span.sentry_tags.op")
.always(), // already guarded by condition on metric
.always(),
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(),
Tag::with_key("transaction.op")
.from_field("span.sentry_tags.transaction.op")
.always(),
// Mobile module:
Tag::with_key("span.description")
.from_field("span.sentry_tags.description")
.always(), // already guarded by condition on metric
.when(app_start_condition.clone()),
Tag::with_key("span.group")
.from_field("span.sentry_tags.group")
.always(), // already guarded by condition on metric
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(), // already guarded by condition on metric
.when(app_start_condition.clone()),
Tag::with_key("device.class")
.from_field("span.sentry_tags.device.class")
.always(), // already guarded by condition on metric
.when(app_start_condition.clone()),
Tag::with_key("release")
.from_field("span.sentry_tags.release")
.always(), // already guarded by condition on metric
.when(app_start_condition.clone()),
Tag::with_key("os.name")
.from_field("span.sentry_tags.os.name")
.always(), // already guarded by condition on metric
Tag::with_key("environment")
.from_field("span.sentry_tags.environment")
.always(), // already guarded by condition on metric
.when(app_start_condition.clone()),
Tag::with_key("app_start_type")
.from_field("span.sentry_tags.app_start_type")
.always(), // already guarded by condition on metric
.when(app_start_condition.clone()),
],
},
MetricSpec {
Expand Down
4 changes: 3 additions & 1 deletion relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ mod tests {
let config = project.metric_extraction.ok().unwrap();
let metrics = extract_metrics(event.value().unwrap(), &config, 200);

assert_eq!(metrics.len(), 4);
assert_eq!(metrics.len(), 5);
assert_eq!(&*metrics[0].name, "c:spans/usage@none");

assert_eq!(&*metrics[1].name, "d:spans/exclusive_time@millisecond");
Expand All @@ -1501,5 +1501,7 @@ mod tests {

assert_eq!(&*metrics[3].name, "c:spans/count_per_op@none");
assert_eq!(&*metrics[3].tags["span.op"], "db.query");

assert_eq!(&*metrics[4].name, "d:spans/duration@millisecond");
}
}
Loading

0 comments on commit a1db65e

Please sign in to comment.