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>
(cherry picked from commit e8faa4a029)
This commit is contained in:
Anders Kaseorg
2025-04-07 18:56:32 -07:00
committed by Tim Abbott
parent 25c8d2abd0
commit e916abf31e

View File

@@ -173,12 +173,16 @@ class QueueProcessingWorker(ABC):
name=f"consume {self.queue_name}",
custom_sampling_context={"queue": self.queue_name},
):
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()},
)
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(),
},
)
try:
if self.idle:
# We're reactivating after having gone idle due to emptying the queue.