Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit ddd8572

Browse files
committed
try catch metrics
1 parent 700382a commit ddd8572

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

upload/views/bundle_analysis.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,22 @@ def get_exception_handler(self) -> Callable:
8080
return repo_auth_custom_exception_handler
8181

8282
def post(self, request: HttpRequest) -> Response:
83-
BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER.labels(
84-
**generate_upload_sentry_metrics_tags(
83+
try:
84+
labels = generate_upload_sentry_metrics_tags(
8585
action="bundle_analysis",
8686
endpoint="bundle_analysis",
8787
request=self.request,
8888
is_shelter_request=self.is_shelter_request(),
8989
position="start",
9090
)
91-
).inc()
91+
BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER.labels(**labels).inc()
92+
except Exception:
93+
log.warn(
94+
"Failed to BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER",
95+
exc_info=True,
96+
extra=labels,
97+
)
98+
9299
serializer = UploadSerializer(data=request.data)
93100
if not serializer.is_valid():
94101
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@@ -167,15 +174,21 @@ def post(self, request: HttpRequest) -> Response:
167174
task_arguments=task_arguments,
168175
),
169176
)
170-
BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER.labels(
171-
**generate_upload_sentry_metrics_tags(
177+
try:
178+
labels = generate_upload_sentry_metrics_tags(
172179
action="bundle_analysis",
173180
endpoint="bundle_analysis",
174181
request=self.request,
175182
is_shelter_request=self.is_shelter_request(),
176183
position="end",
177184
)
178-
).inc()
185+
BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER.labels(**labels).inc()
186+
except Exception:
187+
log.warn(
188+
"Failed to BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER",
189+
exc_info=True,
190+
extra=labels,
191+
)
179192

180193
dispatch_upload_task(
181194
task_arguments,

0 commit comments

Comments
 (0)