Skip to content

Commit

Permalink
fix(trace-view): Web Vitals scores (#81945)
Browse files Browse the repository at this point in the history
The previous formula was incorrect, we need to divide the score by the
weight before multiplying by 100.
  • Loading branch information
0Calories authored Dec 10, 2024
1 parent 0b51b12 commit ef64c9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ export function TraceContextVitals({tree}: Props) {
}

const colors = theme.charts.getColorPalette(3);
const score = Math.round(vital.score * 100);

return (
<VitalMeter
key={vital.key}
webVital={vital.key as WebVitals}
score={score}
score={vital.score}
meterValue={vital.measurement.value}
showTooltip
color={colors[index]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ export function collectTraceMeasurements(
WEB_VITALS_LOOKUP.has(measurement) && vital_types.add('web');
MOBILE_VITALS_LOOKUP.has(measurement) && vital_types.add('mobile');

const score = measurements[`score.${measurement}`]?.value;
const score = Math.round(
(measurements[`score.${measurement}`]?.value /
measurements[`score.weight.${measurement}`]?.value) *
100
);

const vital = vitals.get(node)!;
vital.push({
Expand Down

0 comments on commit ef64c9c

Please sign in to comment.