Skip to content
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 @@ -2,7 +2,6 @@

## Unreleased


**Bug fixes:**

- Respect country code TLDs when scrubbing span tags. ([#3458](https://github.com/getsentry/relay/pull/3458))
Expand All @@ -11,6 +10,7 @@

- Use same keys for OTel span attributes and Sentry span data. ([#3457](https://github.com/getsentry/relay/pull/3457))
- Support passing owner when upserting Monitors. ([#3468](https://github.com/getsentry/relay/pull/3468))
- Extract `frames.slow`, `frames.frozen`, and `frames.total` metrics from mobile spans. ([#3473](https://github.com/getsentry/relay/pull/3473))

**Internal**:

Expand Down
96 changes: 96 additions & 0 deletions relay-dynamic-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,102 @@ fn span_metrics(
.always(), // already guarded by condition on metric
],
},
MetricSpec {
category: DataCategory::Span,
mri: "g:spans/mobile.slow_frames@none".into(),
field: Some("span.measurements.frames.slow.value".into()),
condition: Some(is_mobile.clone() & duration_condition.clone()),
tags: vec![
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(),
Tag::with_key("environment")
.from_field("span.sentry_tags.environment")
.always(),
Tag::with_key("release")
.from_field("span.sentry_tags.release")
.always(),
Tag::with_key("span.description")
.from_field("span.sentry_tags.description")
.always(),
Tag::with_key("span.op")
.from_field("span.sentry_tags.op")
.always(),
Tag::with_key("span.group")
.from_field("span.sentry_tags.group")
.always(),
Tag::with_key("device.class")
.from_field("span.sentry_tags.device.class")
.always(),
Tag::with_key("os.name")
.from_field("span.sentry_tags.os.name")
.always(),
],
},
MetricSpec {
category: DataCategory::Span,
mri: "g:spans/mobile.frozen_frames@none".into(),
field: Some("span.measurements.frames.frozen.value".into()),
condition: Some(is_mobile.clone() & duration_condition.clone()),
tags: vec![
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(),
Tag::with_key("environment")
.from_field("span.sentry_tags.environment")
.always(),
Tag::with_key("release")
.from_field("span.sentry_tags.release")
.always(),
Tag::with_key("span.description")
.from_field("span.sentry_tags.description")
.always(),
Tag::with_key("span.op")
.from_field("span.sentry_tags.op")
.always(),
Tag::with_key("span.group")
.from_field("span.sentry_tags.group")
.always(),
Tag::with_key("device.class")
.from_field("span.sentry_tags.device.class")
.always(),
Tag::with_key("os.name")
.from_field("span.sentry_tags.os.name")
.always(),
],
},
MetricSpec {
category: DataCategory::Span,
mri: "g:spans/mobile.total_frames@none".into(),
field: Some("span.measurements.frames.total.value".into()),
condition: Some(is_mobile.clone() & duration_condition.clone()),
tags: vec![
Tag::with_key("transaction")
.from_field("span.sentry_tags.transaction")
.always(),
Tag::with_key("environment")
.from_field("span.sentry_tags.environment")
.always(),
Tag::with_key("release")
.from_field("span.sentry_tags.release")
.always(),
Tag::with_key("span.description")
.from_field("span.sentry_tags.description")
.always(),
Tag::with_key("span.op")
.from_field("span.sentry_tags.op")
.always(),
Tag::with_key("span.group")
.from_field("span.sentry_tags.group")
.always(),
Tag::with_key("device.class")
.from_field("span.sentry_tags.device.class")
.always(),
Tag::with_key("os.name")
.from_field("span.sentry_tags.os.name")
.always(),
],
},
];

if double_write_distributions_as_gauges {
Expand Down
31 changes: 29 additions & 2 deletions relay-event-normalization/src/normalize/span/tag_extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub fn extract_span_tags(event: &Event, spans: &mut [Annotated<Span>], max_tag_v
.collect(),
);

extract_measurements(span);
extract_measurements(span, is_mobile);
}
}

Expand Down Expand Up @@ -598,7 +598,7 @@ pub fn extract_tags(
}

/// Copies specific numeric values from span data to span measurements.
pub fn extract_measurements(span: &mut Span) {
pub fn extract_measurements(span: &mut Span, is_mobile: bool) {
let Some(span_op) = span.op.as_str() else {
return;
};
Expand Down Expand Up @@ -659,6 +659,33 @@ pub fn extract_measurements(span: &mut Span) {
}
}
}

if is_mobile {
if let Some(data) = span.data.value() {
for (field, key) in [
(&data.frames_frozen, "frames.frozen"),
(&data.frames_slow, "frames.slow"),
(&data.frames_total, "frames.total"),
] {
if let Some(value) = match field.value() {
Some(Value::F64(f)) => Some(*f),
Some(Value::I64(i)) => Some(*i as f64),
Some(Value::U64(u)) => Some(*u as f64),
_ => None,
} {
let measurements = span.measurements.get_or_insert_with(Default::default);
measurements.insert(
key.into(),
Measurement {
value: value.into(),
unit: MetricUnit::None.into(),
}
.into(),
);
}
}
}
}
}

/// Finds first matching span and get its timestamp.
Expand Down
26 changes: 25 additions & 1 deletion relay-event-schema/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ pub struct SpanData {
#[metastructure(field = "sentry.sdk.name")]
pub sdk_name: Annotated<String>,

/// Slow Frames
#[metastructure(field = "sentry.frames.slow", legacy_alias = "frames.slow")]
pub frames_slow: Annotated<Value>,

/// Frozen Frames
#[metastructure(field = "sentry.frames.frozen", legacy_alias = "frames.frozen")]
pub frames_frozen: Annotated<Value>,

/// Total Frames
#[metastructure(field = "sentry.frames.total", legacy_alias = "frames.total")]
pub frames_total: Annotated<Value>,

/// Other fields in `span.data`.
#[metastructure(additional_properties, pii = "true", retain = "true")]
other: Object<Value>,
Expand Down Expand Up @@ -497,7 +509,10 @@ mod tests {
"code.filepath": "task.py",
"code.lineno": 123,
"code.function": "fn()",
"code.namespace": "ns"
"code.namespace": "ns",
"frames.slow": 1,
"frames.frozen": 2,
"frames.total": 9
}"#;
let data = Annotated::<SpanData>::from_json(data)
.unwrap()
Expand Down Expand Up @@ -547,6 +562,15 @@ mod tests {
user: ~,
replay_id: ~,
sdk_name: ~,
frames_slow: I64(
1,
),
frames_frozen: I64(
2,
),
frames_total: I64(
9,
),
other: {
"bar": String(
"3",
Expand Down
3 changes: 3 additions & 0 deletions relay-event-schema/src/protocol/span/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ mod tests {
user: ~,
replay_id: ~,
sdk_name: "sentry.php",
frames_slow: ~,
frames_frozen: ~,
frames_total: ~,
other: {},
},
sentry_tags: ~,
Expand Down
7 changes: 6 additions & 1 deletion relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,12 @@ mod tests {
"span_id": "bd429c44b67a3eb2",
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976303.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81"
"trace_id": "ff62a8b040f340bda5d830223def1d81",
"data": {
"frames.slow": 1,
"frames.frozen": 2,
"frames.total": 9
}
},
{
"op": "app.start.cold",
Expand Down
Loading