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 duration for all spans #3322

Merged
merged 10 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
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()),
iker-barriocanal marked this conversation as resolved.
Show resolved Hide resolved
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
Loading