Browse Source

feat(webvitals): Updates performance score profiles with 0 weight components (#60517)

Adds 0 weight components to performance score profiles. This is needed
to ensure that the sum of all `avg(measurements.score.weight.*)` will
always equal 0. Also updates weights for each webvital to be consistent
across all profiles (this is possible now that we don't require weights
to add up to 1.00 in relay).
edwardgou-sentry 1 year ago
parent
commit
827464cb6e
2 changed files with 20 additions and 10 deletions
  1. 10 5
      src/sentry/relay/config/__init__.py
  2. 10 5
      tests/sentry/relay/test_config.py

+ 10 - 5
src/sentry/relay/config/__init__.py

@@ -407,9 +407,11 @@ def _get_project_config(
                 {
                 {
                     "name": "Firefox",
                     "name": "Firefox",
                     "scoreComponents": [
                     "scoreComponents": [
-                        {"measurement": "fcp", "weight": 0.30, "p10": 900.0, "p50": 1600.0},
-                        {"measurement": "fid", "weight": 0.55, "p10": 100.0, "p50": 300.0},
-                        {"measurement": "ttfb", "weight": 0.15, "p10": 200.0, "p50": 400.0},
+                        {"measurement": "fcp", "weight": 0.15, "p10": 900.0, "p50": 1600.0},
+                        {"measurement": "lcp", "weight": 0.0, "p10": 1200.0, "p50": 2400.0},
+                        {"measurement": "fid", "weight": 0.30, "p10": 100.0, "p50": 300.0},
+                        {"measurement": "cls", "weight": 0.0, "p10": 0.1, "p50": 0.25},
+                        {"measurement": "ttfb", "weight": 0.10, "p10": 200.0, "p50": 400.0},
                     ],
                     ],
                     "condition": {
                     "condition": {
                         "op": "eq",
                         "op": "eq",
@@ -420,8 +422,11 @@ def _get_project_config(
                 {
                 {
                     "name": "Safari",
                     "name": "Safari",
                     "scoreComponents": [
                     "scoreComponents": [
-                        {"measurement": "fcp", "weight": 0.60, "p10": 900.0, "p50": 1600.0},
-                        {"measurement": "ttfb", "weight": 0.40, "p10": 200.0, "p50": 400.0},
+                        {"measurement": "fcp", "weight": 0.15, "p10": 900.0, "p50": 1600.0},
+                        {"measurement": "lcp", "weight": 0.0, "p10": 1200.0, "p50": 2400.0},
+                        {"measurement": "fid", "weight": 0.0, "p10": 100.0, "p50": 300.0},
+                        {"measurement": "cls", "weight": 0.0, "p10": 0.1, "p50": 0.25},
+                        {"measurement": "ttfb", "weight": 0.10, "p10": 200.0, "p50": 400.0},
                     ],
                     ],
                     "condition": {
                     "condition": {
                         "op": "eq",
                         "op": "eq",

+ 10 - 5
tests/sentry/relay/test_config.py

@@ -770,9 +770,11 @@ def test_performance_calculate_score(default_project):
         assert performance_score[1] == {
         assert performance_score[1] == {
             "name": "Firefox",
             "name": "Firefox",
             "scoreComponents": [
             "scoreComponents": [
-                {"measurement": "fcp", "weight": 0.30, "p10": 900.0, "p50": 1600.0},
-                {"measurement": "fid", "weight": 0.55, "p10": 100.0, "p50": 300.0},
-                {"measurement": "ttfb", "weight": 0.15, "p10": 200.0, "p50": 400.0},
+                {"measurement": "fcp", "weight": 0.15, "p10": 900.0, "p50": 1600.0},
+                {"measurement": "lcp", "weight": 0.0, "p10": 1200.0, "p50": 2400.0},
+                {"measurement": "fid", "weight": 0.3, "p10": 100.0, "p50": 300.0},
+                {"measurement": "cls", "weight": 0.0, "p10": 0.1, "p50": 0.25},
+                {"measurement": "ttfb", "weight": 0.1, "p10": 200.0, "p50": 400.0},
             ],
             ],
             "condition": {
             "condition": {
                 "op": "eq",
                 "op": "eq",
@@ -783,8 +785,11 @@ def test_performance_calculate_score(default_project):
         assert performance_score[2] == {
         assert performance_score[2] == {
             "name": "Safari",
             "name": "Safari",
             "scoreComponents": [
             "scoreComponents": [
-                {"measurement": "fcp", "weight": 0.60, "p10": 900.0, "p50": 1600.0},
-                {"measurement": "ttfb", "weight": 0.40, "p10": 200.0, "p50": 400.0},
+                {"measurement": "fcp", "weight": 0.15, "p10": 900.0, "p50": 1600.0},
+                {"measurement": "lcp", "weight": 0.0, "p10": 1200.0, "p50": 2400.0},
+                {"measurement": "fid", "weight": 0.0, "p10": 100.0, "p50": 300.0},
+                {"measurement": "cls", "weight": 0.0, "p10": 0.1, "p50": 0.25},
+                {"measurement": "ttfb", "weight": 0.1, "p10": 200.0, "p50": 400.0},
             ],
             ],
             "condition": {
             "condition": {
                 "op": "eq",
                 "op": "eq",