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

ref(inbound-filters) Remove unused inbound filter health-check feature #52099

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_filter_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def put(self, request: Request, project, filter_id) -> Response:
Update various inbound data filters for a project.
"""

for flt in inbound_filters.get_all_filter_specs(project):
for flt in inbound_filters.get_all_filter_specs():
if flt.id == filter_id:
current_filter = flt
break
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get(self, request: Request, project) -> Response:

"""
results = []
for flt in inbound_filters.get_all_filter_specs(project):
for flt in inbound_filters.get_all_filter_specs():
results.append(
{
"id": flt.id,
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,8 +1647,6 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
"projects:alert-filters": True,
# Enable functionality to specify custom inbound filters on events.
"projects:custom-inbound-filters": False,
# Enable specifying inbound filter for health check calls.
"organizations:health-check-filter": False,
# Enable data forwarding functionality for projects.
"projects:data-forwarding": True,
# Enable functionality to discard groups.
Expand Down
1 change: 0 additions & 1 deletion src/sentry/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
default_manager.add("organizations:codecov-commit-sha-from-git-blame", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
default_manager.add("organizations:ds-sliding-window", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
default_manager.add("organizations:ds-sliding-window-org", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
default_manager.add("organizations:health-check-filter", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
default_manager.add("organizations:pr-comment-bot", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
default_manager.add("organizations:ds-org-recalibration", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)

Expand Down
15 changes: 6 additions & 9 deletions src/sentry/ingest/inbound_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from rest_framework import serializers

from sentry import features
from sentry.api.fields.multiplechoice import MultipleChoiceField
from sentry.models import ProjectOption
from sentry.relay.utils import to_camel_case_name
Expand Down Expand Up @@ -52,7 +51,7 @@ def get_filter_key(flt):
return to_camel_case_name(flt.config_name.replace("-", "_"))


def get_all_filter_specs(project):
def get_all_filter_specs():
"""
Return metadata about the filters known by Sentry.

Expand All @@ -66,16 +65,14 @@ def get_all_filter_specs(project):
_browser_extensions_filter,
_legacy_browsers_filter,
_web_crawlers_filter,
_healthcheck_filter,
]

if features.has("organizations:health-check-filter", project.organization):
filters.append(_healthcheck_filter)

return tuple(filters) # returning tuple for backwards compatibility


def set_filter_state(filter_id, project, state):
flt = _filter_from_filter_id(filter_id, project)
flt = _filter_from_filter_id(filter_id)
if flt is None:
raise FilterNotRegistered(filter_id)

Expand Down Expand Up @@ -124,7 +121,7 @@ def get_filter_state(filter_id, project):
:return: True if the filter is enabled False otherwise
:raises: ValueError if filter id not registered
"""
flt = _filter_from_filter_id(filter_id, project)
flt = _filter_from_filter_id(filter_id)
if flt is None:
raise FilterNotRegistered(filter_id)

Expand Down Expand Up @@ -153,11 +150,11 @@ class FilterNotRegistered(Exception):
pass


def _filter_from_filter_id(filter_id, project):
def _filter_from_filter_id(filter_id):
"""
Returns the corresponding filter for a filter id or None if no filter with the given id found
"""
for flt in get_all_filter_specs(project):
for flt in get_all_filter_specs():
if flt.id == filter_id:
return flt
return None
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/relay/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def get_public_key_configs(
def get_filter_settings(project: Project) -> Mapping[str, Any]:
filter_settings = {}

for flt in get_all_filter_specs(project):
for flt in get_all_filter_specs():
filter_id = get_filter_key(flt)
settings = _load_filter_settings(flt, project)

Expand Down
22 changes: 9 additions & 13 deletions tests/sentry/api/endpoints/test_project_filter_details.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from sentry.testutils import APITestCase
from sentry.testutils.helpers import Feature
from sentry.testutils.silo import region_silo_test


Expand Down Expand Up @@ -33,18 +32,16 @@ def test_put_health_check_filter_business(self):
project = self.create_project(name="Bar", slug="bar", teams=[team])

project.update_option("filters:filtered-transaction", "0")
with Feature("organizations:health-check-filter"):
self.get_success_response(
org.slug, project.slug, "filtered-transaction", active=True, status_code=204
)
self.get_success_response(
org.slug, project.slug, "filtered-transaction", active=True, status_code=204
)
# option was changed by the request
assert project.get_option("filters:filtered-transaction") == "1"

project.update_option("filters:filtered-transaction", "1")
with Feature("organizations:health-check-filter"):
self.get_success_response(
org.slug, project.slug, "filtered-transaction", active=False, status_code=204
)
self.get_success_response(
org.slug, project.slug, "filtered-transaction", active=False, status_code=204
)
# option was changed by the request
assert project.get_option("filters:filtered-transaction") == "0"

Expand All @@ -58,10 +55,9 @@ def test_put_health_check_filter_free_plan(self):
project = self.create_project(name="Bar", slug="bar", teams=[team])

project.update_option("filters:filtered-transaction", "0")
with Feature({"organizations:health-check-filter": False}):
resp = self.get_response(
org.slug, project.slug, "filtered-transaction", active=True, status_code=204
)
resp = self.get_response(
org.slug, project.slug, "filtered-transaction", active=True, status_code=204
)
# check we return error
assert resp.status_code == 404
# check we did not touch the option (the request did not change anything)
Expand Down
28 changes: 4 additions & 24 deletions tests/sentry/api/endpoints/test_project_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from sentry.testutils import APITestCase
from sentry.testutils.helpers import Feature
from sentry.testutils.silo import region_silo_test


Expand Down Expand Up @@ -30,41 +29,22 @@ def test_get(self):

self.insta_snapshot(response.data)

def test_get_business(self):
def test_health_check_filter(self):
"""
Test business plans return health-check-filter
:return:
Tests setting health check filters ( aka filtered-transactions)
"""
org = self.create_organization(name="baz", slug="1", owner=self.user)
team = self.create_team(organization=org, name="foo", slug="foo")
project = self.create_project(name="Bar", slug="bar", teams=[team])

project.update_option("filters:filtered-transaction", "0")
with Feature("organizations:health-check-filter"):
response = self.get_success_response(org.slug, project.slug)
response = self.get_success_response(org.slug, project.slug)
health_check = self.get_filter_spec(response.data, "filtered-transaction")
assert health_check is not None
assert health_check["active"] is False

project.update_option("filters:filtered-transaction", "1")
with Feature("organizations:health-check-filter"):
response = self.get_success_response(org.slug, project.slug)
response = self.get_success_response(org.slug, project.slug)
health_check = self.get_filter_spec(response.data, "filtered-transaction")
assert health_check is not None
assert health_check["active"] is True

def test_free_plan(self):
"""
Tests plans not having "filters:filtered-transaction" feature do not return health-check specs
"""
org = self.create_organization(name="baz", slug="1", owner=self.user)
team = self.create_team(organization=org, name="foo", slug="foo")
project = self.create_project(name="Bar", slug="bar", teams=[team])

# we shouldn't return health check information even if the option is set for the project
# (presumably the user has downgraded from a business plan)
project.update_option("filters:filtered-transaction", "1")
with Feature({"organizations:health-check-filter": False}):
response = self.get_success_response(org.slug, project.slug)
health_check = self.get_filter_spec(response.data, "filtered-transaction")
assert health_check is None
13 changes: 4 additions & 9 deletions tests/sentry/api/endpoints/test_relay_projectconfigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,19 @@ def test_relay_disabled_project(


@pytest.mark.django_db
@pytest.mark.parametrize("is_business", [True, False], ids=["business_plan", "free_plan"])
def test_health_check_filters(call_endpoint, add_org_key, relay, default_project, is_business):
def test_health_check_filters(call_endpoint, add_org_key, relay, default_project):
"""
Test that only business plans contain healthcheck filters
Test health check filter (aka ignoreTransactions)
"""
relay.save()

default_project.update_option("filters:filtered-transaction", "1")
with Feature({"organizations:health-check-filter": is_business}):
result, status_code = call_endpoint(full_config=True)
result, status_code = call_endpoint(full_config=True)

assert status_code < 400

filter_settings = safe.get_path(
result, "configs", str(default_project.id), "config", "filterSettings"
)
assert filter_settings is not None

has_health_check = "ignoreTransactions" in filter_settings

assert has_health_check == is_business
assert "ignoreTransactions" in filter_settings
3 changes: 1 addition & 2 deletions tests/sentry/relay/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ def test_healthcheck_filter(default_project, has_health_check, health_check_set)
"""

default_project.update_option("filters:filtered-transaction", "1" if health_check_set else "0")
with Feature({"organizations:health-check-filter": has_health_check}):
config = get_project_config(default_project).to_dict()["config"]
config = get_project_config(default_project).to_dict()["config"]

_validate_project_config(config)
filter_settings = get_path(config, "filterSettings")
Expand Down