Skip to content

Commit 45c4efc

Browse files
committed
wrap custom sampling ctx with capture_internal_exceptions
1 parent 0ba1ab9 commit 45c4efc

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

sentry_sdk/integrations/celery/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,17 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any":
329329
scope.clear_breadcrumbs()
330330
scope.add_event_processor(_make_event_processor(task, *args, **kwargs))
331331

332-
custom_sampling_context = {
333-
"celery_job": {
334-
"task": task.name,
335-
# for some reason, args[1] is a list if non-empty but a
336-
# tuple if empty
337-
"args": list(args[1]),
338-
"kwargs": args[2],
332+
custom_sampling_context = {}
333+
with capture_internal_exceptions():
334+
custom_sampling_context = {
335+
"celery_job": {
336+
"task": task.name,
337+
# for some reason, args[1] is a list if non-empty but a
338+
# tuple if empty
339+
"args": list(args[1]),
340+
"kwargs": args[2],
341+
}
339342
}
340-
}
341343

342344
span: "Union[Span, StreamedSpan]"
343345
span_ctx: "Union[StreamedSpan, Span, NoOpMgr]" = NoOpMgr()

0 commit comments

Comments
 (0)