Skip to content

Commit d4b0c40

Browse files
mujacicaJoshuaMoelans
authored andcommitted
More PR comment fixes
1 parent c581705 commit d4b0c40

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/sentry/tempest/tasks.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sentry_sdk
66
from django.conf import settings
77
from requests import Response
8-
from requests.exceptions import ConnectionError, ReadTimeout, Timeout
8+
from requests.exceptions import ConnectionError, Timeout
99

1010
from sentry import options
1111
from sentry.locks import locks
@@ -148,7 +148,6 @@ def _fetch_latest_item_id_impl(credentials_id: int) -> None:
148148
credentials.message_type = MessageType.ERROR
149149
credentials.save(update_fields=["message", "message_type"])
150150
return
151-
152151
elif error_type == "ip_not_allowlisted":
153152
credentials.message = "Seems like our IP is not allow-listed"
154153
credentials.message_type = MessageType.ERROR
@@ -160,7 +159,20 @@ def _fetch_latest_item_id_impl(credentials_id: int) -> None:
160159
credentials.message_type = MessageType.ERROR
161160
credentials.save(update_fields=["message", "message_type"])
162161
return
163-
162+
else:
163+
# Unhandled Tempest API error type - record detailed context for debugging.
164+
logger.error(
165+
"Fetching the latest item id failed with Tempest error.",
166+
extra={
167+
"org_id": org_id,
168+
"project_id": project_id,
169+
"client_id": client_id,
170+
"status_code": response.status_code,
171+
"error_type": error_type,
172+
"response_text": result,
173+
},
174+
)
175+
return
164176
# Default in case things go wrong
165177
metrics.incr(
166178
"tempest.latest_id.error",
@@ -181,7 +193,7 @@ def _fetch_latest_item_id_impl(credentials_id: int) -> None:
181193
},
182194
)
183195

184-
except (Timeout, ReadTimeout) as e:
196+
except Timeout as e:
185197
duration_ms = (time.time() - start_time) * 1000
186198
metrics.timing("tempest.latest_id.duration", duration_ms, tags=tags)
187199
metrics.incr("tempest.latest_id.error", tags={**tags, "error_type": "timeout"})
@@ -331,7 +343,7 @@ def _poll_tempest_crashes_impl(credentials_id: int) -> None:
331343
metrics.incr("tempest.crashes.batch_failures", amount=crash_fails, tags=tags)
332344
metrics.incr("tempest.crashes.success", tags=tags)
333345

334-
except (Timeout, ReadTimeout) as e:
346+
except Timeout as e:
335347
duration_ms = (time.time() - start_time) * 1000
336348
metrics.timing("tempest.crashes.duration", duration_ms, tags=tags)
337349
metrics.incr("tempest.crashes.error", tags={**tags, "error_type": "timeout"})

0 commit comments

Comments
 (0)