Skip to content

Commit

Permalink
feature flag check
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardgou-sentry committed Dec 31, 2024
1 parent 980bdeb commit 5615ad4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 41 deletions.
56 changes: 32 additions & 24 deletions src/sentry/search/events/datasets/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.utils.functional import cached_property
from snuba_sdk import Column, Condition, Function, Op, OrderBy

from sentry import features
from sentry.api.event_search import SearchFilter
from sentry.exceptions import IncompatibleMetricsQuery, InvalidSearchQuery
from sentry.search.events import constants, fields
Expand Down Expand Up @@ -1906,30 +1907,37 @@ def _resolve_total_performance_score_function(
scores["inp"],
],
),
Function(
"plus",
[
Function(
"plus",
[
Function(
"plus",
[
Function(
"plus",
[
weights["lcp"],
weights["fcp"],
],
),
weights["cls"],
],
),
weights["ttfb"],
],
),
weights["inp"],
],
(
Function(
"plus",
[
Function(
"plus",
[
Function(
"plus",
[
Function(
"plus",
[
weights["lcp"],
weights["fcp"],
],
),
weights["cls"],
],
),
weights["ttfb"],
],
),
weights["inp"],
],
)
if features.has(
"organizations:performance-vitals-handle-missing-webvitals",
self.builder.params.organization,
)
else 1
),
],
alias,
Expand Down
35 changes: 18 additions & 17 deletions tests/snuba/api/endpoints/test_organization_events_mep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3125,23 +3125,24 @@ def test_total_performance_score_with_missing_vitals(self):
tags={"transaction": "foo_transaction", "transaction.op": "pageload"},
timestamp=self.min_ago,
)
response = self.do_request(
{
"field": [
"transaction",
"performance_score(measurements.score.total)",
],
"query": "",
"dataset": "metrics",
"per_page": 50,
}
)
assert response.status_code == 200, response.content
assert len(response.data["data"]) == 1
data = response.data["data"]
meta = response.data["meta"]
assert data[0]["performance_score(measurements.score.total)"] == 0.4
assert meta["isMetricsData"]
with self.feature({"organizations:performance-vitals-handle-missing-webvitals": True}):
response = self.do_request(
{
"field": [
"transaction",
"performance_score(measurements.score.total)",
],
"query": "",
"dataset": "metrics",
"per_page": 50,
}
)
assert response.status_code == 200, response.content
assert len(response.data["data"]) == 1
data = response.data["data"]
meta = response.data["meta"]
assert data[0]["performance_score(measurements.score.total)"] == 0.4
assert meta["isMetricsData"]

def test_count_scores(self):
self.store_transaction_metric(
Expand Down

0 comments on commit 5615ad4

Please sign in to comment.