Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(metric-issues): Add project-level flag for metric issues #84316

Merged
merged 2 commits into from
Jan 30, 2025
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
1 change: 1 addition & 0 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def register_temporary_features(manager: FeatureManager):
manager.add("organizations:issue-views-page-filter", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
manager.add("organizations:large-debug-files", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, api_expose=False)
manager.add("organizations:metric-issue-poc", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
manager.add("projects:metric-issue-creation", ProjectFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:issue-open-periods", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:mep-rollout-flag", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
manager.add("organizations:mep-use-default-tags", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
Expand Down
6 changes: 6 additions & 0 deletions src/sentry/incidents/utils/metric_issue_poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any
from uuid import uuid4

from sentry import features
from sentry.incidents.models.incident import Incident, IncidentStatus
from sentry.integrations.metric_alerts import get_incident_status_text
from sentry.issues.grouptype import MetricIssuePOC
Expand Down Expand Up @@ -71,6 +72,11 @@ def create_or_update_metric_issue(
if not project:
return None

if not features.has("projects:metric-issue-creation", project):
# We've already checked for the feature flag at the organization level,
# but this flag helps us test with a smaller set of projects.
return None

# collect the data from the incident to treat as an event
event_data: dict[str, Any] = {
"event_id": uuid4().hex,
Expand Down
2 changes: 2 additions & 0 deletions tests/sentry/incidents/test_subscription_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,6 +2878,7 @@ def test_incident_made_after_ten_minutes(self):
self.assert_incident_is_latest_for_rule(new_incident)

@with_feature("organizations:metric-issue-poc")
@with_feature("projects:metric-issue-creation")
@mock.patch("sentry.incidents.utils.metric_issue_poc.produce_occurrence_to_kafka")
def test_alert_creates_metric_issue(self, mock_produce_occurrence_to_kafka):
rule = self.rule
Expand Down Expand Up @@ -2907,6 +2908,7 @@ def test_alert_creates_metric_issue(self, mock_produce_occurrence_to_kafka):
assert occurrence.evidence_data["metric_value"] == trigger.alert_threshold + 1

@with_feature("organizations:metric-issue-poc")
@with_feature("projects:metric-issue-creation")
@mock.patch("sentry.incidents.utils.metric_issue_poc.produce_occurrence_to_kafka")
def test_resolved_alert_updates_metric_issue(self, mock_produce_occurrence_to_kafka):
from sentry.models.group import GroupStatus
Expand Down
1 change: 1 addition & 0 deletions tests/sentry/incidents/utils/test_metric_issue_poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


@apply_feature_flag_on_cls("organizations:metric-issue-poc-ingest")
@apply_feature_flag_on_cls("projects:metric-issue-creation")
class TestMetricIssuePOC(IssueOccurrenceTestBase, APITestCase):
def setUp(self):
self.organization = self.create_organization()
Expand Down
Loading