worker: Check if Sentry is initialized before calling add_breadcrumb.

Otherwise we get spammed with “Dropped breadcrumb because no client
bound” log messages.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2025-04-07 18:56:32 -07:00
committed by Tim Abbott
parent e4a2695f54
commit e8faa4a029

View File

@@ -173,11 +173,15 @@ class QueueProcessingWorker(ABC):
name=f"consume {self.queue_name}",
custom_sampling_context={"queue": self.queue_name},
):
if sentry_sdk.is_initialized():
sentry_sdk.add_breadcrumb(
type="debug",
category="queue_processor",
message=f"Consuming {self.queue_name}",
data={"events": events, "local_queue_size": self.get_remaining_local_queue_size()},
data={
"events": events,
"local_queue_size": self.get_remaining_local_queue_size(),
},
)
try:
if self.idle: