Skip to content

Commit

Permalink
feat(webvitals): Updates performance score values to use 0-1 cdf valu…
Browse files Browse the repository at this point in the history
…es instead of the actual raw component score (#2734)

Updates web vital performance score component values to use 0 - 1 cdf
values instead of the actual raw component score. The raw component
scores have dynamic upper bounds depending on the component weights
provided, so we should use the cdf values since they're bound between 0
- 1 (which we can combine with the weight to get the actual score in the
product).
  • Loading branch information
edwardgou-sentry authored Nov 21, 2023
1 parent 9092af5 commit fc0a6ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- `normalize_performance_score` stores 0 to 1 cdf score instead of weighted score for each performance score component. ([#2734](https://github.com/getsentry/relay/pull/2734))

**Bug Fixes**:

- Fix bug introduced in 23.11.0 that broke profile-transaction association. ([#2733](https://github.com/getsentry/relay/pull/2733))
Expand Down
4 changes: 4 additions & 0 deletions py/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- `normalize_performance_score` stores 0 to 1 cdf score instead of weighted score for each performance score component. ([#2734](https://github.com/getsentry/relay/pull/2734))

## 0.8.37

- License is now FSL instead of BSL ([#2739](https://github.com/getsentry/relay/pull/2739))
Expand Down
21 changes: 11 additions & 10 deletions relay-event-normalization/src/normalize/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,18 +884,19 @@ fn normalize_performance_score(
break;
}
let mut score_total = 0.0;
let mut weight_total = 0.0;
for component in &profile.score_components {
if let Some(value) = measurements.get_value(component.measurement.as_str()) {
let subscore =
utils::calculate_cdf_score(value, component.p10, component.p50)
* component.weight;
score_total += subscore;
let cdf = utils::calculate_cdf_score(value, component.p10, component.p50);
let component_score = cdf * component.weight;
score_total += component_score;
weight_total += component.weight;
should_add_total = true;

measurements.insert(
format!("score.{}", component.measurement),
Measurement {
value: subscore.into(),
value: cdf.into(),
unit: (MetricUnit::Fraction(FractionUnit::Ratio)).into(),
}
.into(),
Expand All @@ -915,7 +916,7 @@ fn normalize_performance_score(
measurements.insert(
"score.total".to_owned(),
Measurement {
value: score_total.into(),
value: (score_total / weight_total).into(),
unit: (MetricUnit::Fraction(FractionUnit::Ratio)).into(),
}
.into(),
Expand Down Expand Up @@ -2169,19 +2170,19 @@ mod tests {
"unit": "millisecond",
},
"score.cls": {
"value": 0.21864170607444863,
"value": 0.8745668242977945,
"unit": "ratio",
},
"score.fcp": {
"value": 0.10750855443790831,
"value": 0.7167236962527221,
"unit": "ratio",
},
"score.fid": {
"value": 0.19657361348282545,
"value": 0.6552453782760849,
"unit": "ratio",
},
"score.lcp": {
"value": 0.009238896571386584,
"value": 0.03079632190462195,
"unit": "ratio",
},
"score.total": {
Expand Down

0 comments on commit fc0a6ec

Please sign in to comment.