Skip to content

Commit 8e16508

Browse files
committed
Remove sentry exception capture for thumbnail errors
1 parent 8c064fd commit 8e16508

File tree

3 files changed

+6
-56
lines changed

3 files changed

+6
-56
lines changed

api/api/utils/image_proxy/__init__.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
import aiohttp
1212
import django_redis
13-
import sentry_sdk
1413
from aiohttp.client_exceptions import ClientResponseError
1514
from asgiref.sync import sync_to_async
1615
from redis.exceptions import ConnectionError
17-
from sentry_sdk import push_scope, set_context
1816

1917
from api.utils.aiohttp import get_aiohttp_session
2018
from api.utils.asyncio import do_not_wait_for
@@ -192,28 +190,10 @@ async def get(
192190
exception_name = f"{exc.__class__.__module__}.{exc.__class__.__name__}"
193191
key = f"thumbnail_error:{exception_name}:{domain}:{month}"
194192
try:
195-
count = await tallies_incr(key)
193+
await tallies_incr(key)
196194
except ConnectionError:
197195
logger.warning("Redis connect failed, thumbnail errors not tallied.")
198-
# We will use a counter to space out Sentry logs.
199-
count = next(exception_iterator)
200-
201-
if count <= settings.THUMBNAIL_ERROR_INITIAL_ALERT_THRESHOLD or (
202-
count % settings.THUMBNAIL_ERROR_REPEATED_ALERT_FREQUENCY == 0
203-
):
204-
with push_scope() as scope:
205-
set_context(
206-
"upstream_url",
207-
{
208-
"url": upstream_url,
209-
"params": params,
210-
"headers": headers,
211-
},
212-
)
213-
scope.set_tag(
214-
"occurrences", settings.THUMBNAIL_ERROR_REPEATED_ALERT_FREQUENCY
215-
)
216-
sentry_sdk.capture_exception(exc)
196+
217197
if isinstance(exc, ClientResponseError):
218198
status = exc.status
219199
do_not_wait_for(

api/conf/settings/thumbnails.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,3 @@
1515
# to cast them in assertions to match the parsed param types)
1616
THUMBNAIL_WIDTH_PX = config("THUMBNAIL_WIDTH_PX", default="600")
1717
THUMBNAIL_QUALITY = config("THUMBNAIL_JPG_QUALITY", default="80")
18-
19-
THUMBNAIL_ERROR_INITIAL_ALERT_THRESHOLD = config(
20-
"THUMBNAIL_ERROR_INITIAL_ALERT_THRESHOLD", default=100, cast=int
21-
)
22-
23-
THUMBNAIL_ERROR_REPEATED_ALERT_FREQUENCY = config(
24-
"THUMBNAIL_ERROR_REPEATED_ALERT_FREQUENCY", default=1000, cast=int
25-
)

api/test/unit/utils/test_image_proxy.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,8 @@ def test_get_successful_records_response_code(
331331

332332

333333
alert_count_params = pytest.mark.parametrize(
334-
"count_start, should_alert",
335-
[
336-
(0, True),
337-
(1, True),
338-
(50, True),
339-
(99, True),
340-
(100, False),
341-
(999, True),
342-
(1000, False),
343-
(1500, False),
344-
(1999, True),
345-
],
334+
"count_start",
335+
[0, 1, 50, 99, 100, 999, 1000, 1500, 1999],
346336
)
347337

348338
MOCK_CONNECTION_KEY = ConnectionKey(
@@ -385,7 +375,6 @@ def test_get_exception_handles_error(
385375
exc,
386376
exc_name,
387377
count_start,
388-
should_alert,
389378
sentry_capture_exception,
390379
setup_request_exception,
391380
is_cache_reachable,
@@ -409,12 +398,7 @@ def test_get_exception_handles_error(
409398
):
410399
photon_get(TEST_MEDIA_INFO)
411400

412-
assert_func = (
413-
sentry_capture_exception.assert_called_once
414-
if should_alert
415-
else sentry_capture_exception.assert_not_called
416-
)
417-
assert_func()
401+
sentry_capture_exception.assert_not_called()
418402

419403
if is_cache_reachable:
420404
assert cache.get(key) == str(count_start + 1).encode()
@@ -438,7 +422,6 @@ def test_get_http_exception_handles_error(
438422
status_code,
439423
text,
440424
count_start,
441-
should_alert,
442425
sentry_capture_exception,
443426
is_cache_reachable,
444427
cache_name,
@@ -459,12 +442,7 @@ def test_get_http_exception_handles_error(
459442
pook.get(PHOTON_URL_FOR_TEST_IMAGE).reply(status_code, text)
460443
photon_get(TEST_MEDIA_INFO)
461444

462-
assert_func = (
463-
sentry_capture_exception.assert_called_once
464-
if should_alert
465-
else sentry_capture_exception.assert_not_called
466-
)
467-
assert_func()
445+
sentry_capture_exception.assert_not_called()
468446

469447
if is_cache_reachable:
470448
assert cache.get(key) == str(count_start + 1).encode()

0 commit comments

Comments
 (0)