Skip to content

Commit 9284340

Browse files
authored
ref: Remove old interface validation code (#13332)
cont #12375
1 parent 09c1509 commit 9284340

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+330
-1070
lines changed

.travis.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ matrix:
130130
name: 'Backend [Postgres] (2/2)'
131131
env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=1
132132

133-
# XXX(markus): Remove after rust interfaces are done
134-
- <<: *postgres_default
135-
name: 'Backend [Postgres] (Rust Interface Renormalization)'
136-
env: TEST_SUITE=postgres DB=postgres SENTRY_TEST_USE_RUST_INTERFACE_RENORMALIZATION=1
137-
138133
- python: 2.7
139134
name: 'Backend [Riak]'
140135
env: TEST_SUITE=riak DB=postgres
@@ -157,12 +152,6 @@ matrix:
157152
name: 'Acceptance'
158153
env: TEST_SUITE=acceptance USE_SNUBA=1
159154

160-
# XXX(markus): Remove after rust interfaces are done
161-
- <<: *acceptance_default
162-
python: 2.7
163-
name: 'Acceptance (Rust Interface Renormalization)'
164-
env: TEST_SUITE=acceptance USE_SNUBA=1 SENTRY_TEST_USE_RUST_INTERFACE_RENORMALIZATION=1 PERCY_ENABLE=0
165-
166155
- python: 2.7
167156
name: 'Frontend'
168157
env: TEST_SUITE=js
@@ -224,28 +213,6 @@ matrix:
224213
before_script:
225214
- psql -c 'create database sentry;' -U postgres
226215

227-
# XXX(markus): Remove after rust interfaces are done
228-
- python: 2.7
229-
name: 'Snuba Integration (Rust Interface Renormalization)'
230-
env: TEST_SUITE=snuba USE_SNUBA=1 SENTRY_ZOOKEEPER_HOSTS=localhost:2181 SENTRY_KAFKA_HOSTS=localhost:9092 SENTRY_TEST_USE_RUST_INTERFACE_RENORMALIZATION=1
231-
services:
232-
- docker
233-
- memcached
234-
- redis-server
235-
- postgresql
236-
before_install:
237-
- docker run -d --network host --name zookeeper -e ZOOKEEPER_CLIENT_PORT=2181 confluentinc/cp-zookeeper:4.1.0
238-
- docker run -d --network host --name kafka -e KAFKA_ZOOKEEPER_CONNECT=localhost:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 confluentinc/cp-kafka:4.1.0
239-
- docker run -d --network host --name clickhouse-server --ulimit nofile=262144:262144 yandex/clickhouse-server:18.14.9
240-
- docker run -d --network host --name snuba --env SNUBA_SETTINGS=test --env CLICKHOUSE_SERVER=localhost:9000 getsentry/snuba
241-
- docker ps -a
242-
install:
243-
- python setup.py install_egg_info
244-
- pip install -e ".[dev,tests,optional]"
245-
- pip install confluent-kafka
246-
before_script:
247-
- psql -c 'create database sentry;' -U postgres
248-
249216
# Deploy 'storybook' (component & style guide) - allowed to fail
250217
- language: node_js
251218
name: 'Storybook Deploy'
@@ -278,9 +245,6 @@ matrix:
278245
# is changed.
279246
- env: TEST_SUITE=symbolicator
280247

281-
# XXX(markus): Remove after rust interfaces are done
282-
- env: TEST_SUITE=postgres DB=postgres SENTRY_TEST_USE_RUST_INTERFACE_RENORMALIZATION=1
283-
284248
notifications:
285249
webhooks:
286250
urls:

requirements-base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ redis>=2.10.3,<2.10.6
5656
requests-oauthlib==0.3.3
5757
requests[security]>=2.20.0,<2.21.0
5858
selenium==3.141.0
59-
semaphore>=0.4.34,<0.5.0
59+
semaphore>=0.4.35,<0.5.0
6060
sentry-sdk>=0.8.0
6161
setproctitle>=1.1.7,<1.2.0
6262
simplejson>=3.2.0,<3.9.0

src/sentry/interfaces/base.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import absolute_import
22

3-
import os
43

54
from collections import OrderedDict
65
import logging
@@ -19,14 +18,6 @@
1918
logger = logging.getLogger("sentry.events")
2019
interface_logger = logging.getLogger("sentry.interfaces")
2120

22-
# This flag is only effectively used for the testsuite. In production the
23-
# return value of `sentry.models.event._should_skip_to_python` is explicitly
24-
# passed to interfaces.
25-
RUST_RENORMALIZED_DEFAULT = os.environ.get(
26-
"SENTRY_TEST_USE_RUST_INTERFACE_RENORMALIZATION",
27-
"false"
28-
).lower() in ("true", "1")
29-
3021

3122
def get_interface(name):
3223
try:
@@ -43,7 +34,7 @@ def get_interface(name):
4334
return interface
4435

4536

46-
def get_interfaces(data, rust_renormalized=RUST_RENORMALIZED_DEFAULT):
37+
def get_interfaces(data):
4738
result = []
4839
for key, data in six.iteritems(data):
4940
# Skip invalid interfaces that were nulled out during normalization
@@ -55,9 +46,7 @@ def get_interfaces(data, rust_renormalized=RUST_RENORMALIZED_DEFAULT):
5546
except ValueError:
5647
continue
5748

58-
value = safe_execute(cls.to_python, data,
59-
rust_renormalized=rust_renormalized,
60-
_with_transaction=False)
49+
value = safe_execute(cls.to_python, data, _with_transaction=False)
6150
if not value:
6251
continue
6352

@@ -139,7 +128,7 @@ def __setattr__(self, name, value):
139128
self._data[name] = value
140129

141130
@classmethod
142-
def to_python(cls, data, rust_renormalized=RUST_RENORMALIZED_DEFAULT):
131+
def to_python(cls, data):
143132
"""Creates a python interface object from the given raw data.
144133
145134
This function can assume fully normalized and valid data. It can create

src/sentry/interfaces/breadcrumbs.py

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
__all__ = ('Breadcrumbs', )
1212

13-
import six
14-
15-
from sentry.constants import LOG_LEVELS_MAP
16-
from sentry.interfaces.base import Interface, InterfaceValidationError, prune_empty_keys, RUST_RENORMALIZED_DEFAULT
17-
from sentry.utils.safe import get_path, trim
13+
from sentry.interfaces.base import Interface, prune_empty_keys
14+
from sentry.utils.safe import get_path
1815
from sentry.utils.dates import to_timestamp, to_datetime, parse_timestamp
1916

2017

@@ -37,19 +34,11 @@ class Breadcrumbs(Interface):
3734
score = 800
3835

3936
@classmethod
40-
def to_python(cls, data, rust_renormalized=RUST_RENORMALIZED_DEFAULT):
37+
def to_python(cls, data):
4138
values = []
4239
for index, crumb in enumerate(get_path(data, 'values', filter=True, default=())):
4340
# TODO(ja): Handle already invalid and None breadcrumbs
44-
45-
try:
46-
values.append(cls.normalize_crumb(crumb, rust_renormalized=rust_renormalized))
47-
except Exception:
48-
# TODO(dcramer): we dont want to discard the entirety of data
49-
# when one breadcrumb errors, but it'd be nice if we could still
50-
# record an error
51-
if rust_renormalized:
52-
raise
41+
values.append(cls.normalize_crumb(crumb))
5342

5443
return cls(values=values)
5544

@@ -69,70 +58,25 @@ def to_json(self):
6958
})
7059

7160
@classmethod
72-
def normalize_crumb(cls, crumb, rust_renormalized):
73-
if rust_renormalized:
74-
crumb = dict(crumb)
75-
ts = parse_timestamp(crumb.get('timestamp'))
76-
if ts:
77-
crumb['timestamp'] = to_timestamp(ts)
78-
else:
79-
crumb['timestamp'] = None
80-
81-
for key in (
82-
'type',
83-
'level',
84-
'message',
85-
'category',
86-
'event_id',
87-
'data',
88-
):
89-
crumb.setdefault(key, None)
90-
91-
return crumb
92-
93-
ty = crumb.get('type') or 'default'
94-
level = crumb.get('level')
95-
if not isinstance(level, six.string_types) or \
96-
(level not in LOG_LEVELS_MAP and level != 'critical'):
97-
level = 'info'
98-
61+
def normalize_crumb(cls, crumb):
62+
crumb = dict(crumb)
9963
ts = parse_timestamp(crumb.get('timestamp'))
100-
if ts is None:
101-
raise InterfaceValidationError('Unable to determine timestamp for crumb')
102-
ts = to_timestamp(ts)
103-
104-
msg = crumb.get('message')
105-
if msg is not None:
106-
msg = trim(six.text_type(msg), 4096)
107-
108-
category = crumb.get('category')
109-
if category is not None:
110-
category = trim(six.text_type(category), 256)
111-
112-
event_id = crumb.get('event_id')
113-
114-
data = crumb.get('data')
115-
if not isinstance(data, dict):
116-
# TODO(dcramer): we dont want to discard the the rest of the
117-
# crumb, but it'd be nice if we could record an error
118-
# raise InterfaceValidationError(
119-
# 'The ``data`` on breadcrumbs must be a mapping (received {})'.format(
120-
# type(crumb['data']),
121-
# )
122-
# )
123-
data = None
64+
if ts:
65+
crumb['timestamp'] = to_timestamp(ts)
12466
else:
125-
data = trim(data, 4096)
126-
127-
return {
128-
'type': ty,
129-
'level': level,
130-
'timestamp': ts,
131-
'message': msg,
132-
'category': category,
133-
'event_id': event_id,
134-
'data': data
135-
}
67+
crumb['timestamp'] = None
68+
69+
for key in (
70+
'type',
71+
'level',
72+
'message',
73+
'category',
74+
'event_id',
75+
'data',
76+
):
77+
crumb.setdefault(key, None)
78+
79+
return crumb
13680

13781
def get_api_context(self, is_public=False, platform=None):
13882
def _convert(x):

src/sentry/interfaces/contexts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from django.utils.encoding import force_text
1515

16-
from sentry.interfaces.base import Interface, prune_empty_keys, RUST_RENORMALIZED_DEFAULT
16+
from sentry.interfaces.base import Interface, prune_empty_keys
1717
from sentry.utils.contexts_normalization import normalize_os, normalize_runtime
1818
from sentry.utils.safe import get_path, trim
1919

@@ -186,7 +186,7 @@ class Contexts(Interface):
186186
score = 800
187187

188188
@classmethod
189-
def to_python(cls, data, rust_renormalized=RUST_RENORMALIZED_DEFAULT):
189+
def to_python(cls, data):
190190
rv = {}
191191
for alias, value in six.iteritems(data):
192192
# XXX(markus): The `None`-case should be handled in the UI and

0 commit comments

Comments
 (0)