Skip to content
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
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rest_framework.response import Response

from sentry import features
from sentry.utils.data_filters import FilterTypes
from sentry.ingest.inbound_filters import FilterTypes
from sentry.api.base import DocSection
from sentry.api.bases.project import ProjectEndpoint, ProjectPermission
from sentry.api.decorators import sudo_required
Expand Down
8 changes: 4 additions & 4 deletions src/sentry/api/endpoints/project_filter_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from rest_framework.response import Response

from sentry import message_filters
from sentry.ingest import inbound_filters
from sentry.api.bases.project import ProjectEndpoint
from sentry.api.exceptions import ResourceDoesNotExist
from sentry.models.auditlogentry import AuditLogEntryEvent
Expand All @@ -19,7 +19,7 @@ def put(self, request, project, filter_id):

"""
current_filter = None
for flt in message_filters.get_all_filter_specs():
for flt in inbound_filters.get_all_filter_specs():
if flt.id == filter_id:
current_filter = flt
break
Expand All @@ -31,9 +31,9 @@ def put(self, request, project, filter_id):
if not serializer.is_valid():
return Response(serializer.errors, status=400)

current_state = message_filters.get_filter_state(filter_id, project)
current_state = inbound_filters.get_filter_state(filter_id, project)

new_state = message_filters.set_filter_state(filter_id, project, serializer.validated_data)
new_state = inbound_filters.set_filter_state(filter_id, project, serializer.validated_data)
audit_log_state = AuditLogEntryEvent.PROJECT_ENABLE

if filter_id == "legacy-browsers":
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/api/endpoints/project_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from rest_framework.response import Response

from sentry import message_filters
from sentry.ingest import inbound_filters
from sentry.api.bases.project import ProjectEndpoint


Expand All @@ -17,13 +17,13 @@ def get(self, request, project):

"""
results = []
for flt in message_filters.get_all_filter_specs():
for flt in inbound_filters.get_all_filter_specs():
results.append(
{
"id": flt.id,
# 'active' will be either a boolean or list for the legacy browser filters
# all other filters will be boolean
"active": message_filters.get_filter_state(flt.id, project),
"active": inbound_filters.get_filter_state(flt.id, project),
"description": flt.description,
"name": flt.name,
"hello": flt.id + " - " + flt.name,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sentry.api.bases.project import ProjectEndpoint
from sentry.api.exceptions import ResourceDoesNotExist
from sentry.models import Environment
from sentry.utils.data_filters import FILTER_STAT_KEYS_TO_VALUES
from sentry.ingest.inbound_filters import FILTER_STAT_KEYS_TO_VALUES
from sentry.utils.apidocs import scenario, attach_scenarios


Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/serializers/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
UserOption,
UserReport,
)
from sentry.utils.data_filters import FilterTypes
from sentry.ingest.inbound_filters import FilterTypes
from sentry.utils.compat import zip

STATUS_LABELS = {
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from sentry.tasks.integrations import kick_off_status_syncs
from sentry.utils import json, metrics
from sentry.utils.canonical import CanonicalKeyDict
from sentry.utils.data_filters import FilterStatKeys
from sentry.ingest.inbound_filters import FilterStatKeys
from sentry.utils.dates import to_timestamp, to_datetime
from sentry.utils.outcomes import Outcome, track_outcome
from sentry.utils.safe import safe_execute, trim, get_path, setdefault_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,53 @@

from rest_framework import serializers

from sentry import tsdb
from sentry.relay.utils import to_camel_case_name
from sentry.api.fields.multiplechoice import MultipleChoiceField
from sentry.models.projectoption import ProjectOption
from sentry.signals import inbound_filter_toggled
from sentry.utils.data_filters import FilterStatKeys, get_filter_key


class FilterStatKeys(object):
"""
NOTE: This enum also exists in Relay, check if alignment is needed when
editing this.
"""

IP_ADDRESS = "ip-address"
RELEASE_VERSION = "release-version"
ERROR_MESSAGE = "error-message"
BROWSER_EXTENSION = "browser-extensions"
LEGACY_BROWSER = "legacy-browsers"
LOCALHOST = "localhost"
WEB_CRAWLER = "web-crawlers"
INVALID_CSP = "invalid-csp"
CORS = "cors"
DISCARDED_HASH = "discarded-hash" # Not replicated in Relay
CRASH_REPORT_LIMIT = "crash-report-limit" # Not replicated in Relay


FILTER_STAT_KEYS_TO_VALUES = {
FilterStatKeys.IP_ADDRESS: tsdb.models.project_total_received_ip_address,
FilterStatKeys.RELEASE_VERSION: tsdb.models.project_total_received_release_version,
FilterStatKeys.ERROR_MESSAGE: tsdb.models.project_total_received_error_message,
FilterStatKeys.BROWSER_EXTENSION: tsdb.models.project_total_received_browser_extensions,
FilterStatKeys.LEGACY_BROWSER: tsdb.models.project_total_received_legacy_browsers,
FilterStatKeys.LOCALHOST: tsdb.models.project_total_received_localhost,
FilterStatKeys.WEB_CRAWLER: tsdb.models.project_total_received_web_crawlers,
FilterStatKeys.INVALID_CSP: tsdb.models.project_total_received_invalid_csp,
FilterStatKeys.CORS: tsdb.models.project_total_received_cors,
FilterStatKeys.DISCARDED_HASH: tsdb.models.project_total_received_discarded,
}


class FilterTypes(object):
ERROR_MESSAGES = "error_messages"
RELEASES = "releases"


def get_filter_key(flt):
return to_camel_case_name(flt.id.replace("-", "_"))


def get_all_filter_specs():
Expand Down
8 changes: 6 additions & 2 deletions src/sentry/relay/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
from sentry.constants import ObjectStatus
from sentry.grouping.api import get_grouping_config_dict_for_project
from sentry.interfaces.security import DEFAULT_DISALLOWED_SOURCES
from sentry.message_filters import get_all_filter_specs
from sentry.utils.data_filters import FilterTypes, FilterStatKeys, get_filter_key
from sentry.ingest.inbound_filters import (
get_all_filter_specs,
FilterTypes,
FilterStatKeys,
get_filter_key,
)
from sentry.utils.http import get_origins
from sentry.utils.sdk import configure_scope
from sentry.relay.utils import to_camel_case_name
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/tsdb/snuba.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from sentry.tsdb.base import BaseTSDB, TSDBModel
from sentry.utils import snuba, outcomes
from sentry.utils.data_filters import FILTER_STAT_KEYS_TO_VALUES
from sentry.ingest.inbound_filters import FILTER_STAT_KEYS_TO_VALUES
from sentry.utils.dates import to_datetime
from sentry.utils.compat import map
from sentry.utils.compat import zip
Expand Down
46 changes: 0 additions & 46 deletions src/sentry/utils/data_filters.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/sentry/utils/outcomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sentry import tsdb, options
from sentry.constants import DataCategory
from sentry.utils import json, metrics
from sentry.utils.data_filters import FILTER_STAT_KEYS_TO_VALUES
from sentry.ingest.inbound_filters import FILTER_STAT_KEYS_TO_VALUES
from sentry.utils.dates import to_datetime
from sentry.utils.pubsub import KafkaPublisher

Expand Down
2 changes: 1 addition & 1 deletion tests/relay_integration/test_message_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sentry.testutils import TransactionTestCase, RelayStoreHelper
from sentry.models.projectoption import ProjectOption
from sentry.utils.safe import set_path
from sentry.message_filters import (
from sentry.ingest.inbound_filters import (
_localhost_filter,
_browser_extensions_filter,
_web_crawlers_filter,
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/event_manager/test_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from sentry.utils.cache import cache_key_for_event
from sentry.utils.outcomes import Outcome
from sentry.testutils import assert_mock_called_once_with_partial, TestCase
from sentry.utils.data_filters import FilterStatKeys
from sentry.ingest.inbound_filters import FilterStatKeys


def make_event(**kwargs):
Expand Down