mirror of https://github.com/zulip/zulip.git
missedmessage_emails: Add Sentry spans to worker thread.
This commit is contained in:
parent
9451d08bb9
commit
9d8d2d138b
|
@ -620,6 +620,7 @@ class MissedMessageWorker(QueueProcessingWorker):
|
||||||
# The main thread, which handles the RabbitMQ connection and creates
|
# The main thread, which handles the RabbitMQ connection and creates
|
||||||
# database rows from them.
|
# database rows from them.
|
||||||
@override
|
@override
|
||||||
|
@sentry_sdk.trace
|
||||||
def consume(self, event: Dict[str, Any]) -> None:
|
def consume(self, event: Dict[str, Any]) -> None:
|
||||||
logging.debug("Processing missedmessage_emails event: %s", event)
|
logging.debug("Processing missedmessage_emails event: %s", event)
|
||||||
# When we consume an event, check if there are existing pending emails
|
# When we consume an event, check if there are existing pending emails
|
||||||
|
@ -693,6 +694,11 @@ class MissedMessageWorker(QueueProcessingWorker):
|
||||||
|
|
||||||
def work(self) -> None:
|
def work(self) -> None:
|
||||||
while True:
|
while True:
|
||||||
|
with sentry_sdk.start_transaction(
|
||||||
|
op="task",
|
||||||
|
name=f"{self.queue_name} worker thread",
|
||||||
|
custom_sampling_context={"queue": self.queue_name},
|
||||||
|
):
|
||||||
flush_per_request_caches()
|
flush_per_request_caches()
|
||||||
reset_queries()
|
reset_queries()
|
||||||
try:
|
try:
|
||||||
|
@ -747,7 +753,10 @@ class MissedMessageWorker(QueueProcessingWorker):
|
||||||
# re-checking the condition.
|
# re-checking the condition.
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
with sentry_sdk.start_span(description="condvar wait") as span:
|
||||||
|
span.set_data("timeout", timeout)
|
||||||
was_notified = self.cv.wait_for(wait_condition, timeout=timeout)
|
was_notified = self.cv.wait_for(wait_condition, timeout=timeout)
|
||||||
|
span.set_data("was_notified", was_notified)
|
||||||
|
|
||||||
# Being notified means that we are in conditions (1) or
|
# Being notified means that we are in conditions (1) or
|
||||||
# (2), above. In neither case do we need to look at if
|
# (2), above. In neither case do we need to look at if
|
||||||
|
@ -759,6 +768,7 @@ class MissedMessageWorker(QueueProcessingWorker):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@sentry_sdk.trace
|
||||||
def maybe_send_batched_emails(self) -> None:
|
def maybe_send_batched_emails(self) -> None:
|
||||||
current_time = timezone_now()
|
current_time = timezone_now()
|
||||||
|
|
||||||
|
@ -782,6 +792,11 @@ class MissedMessageWorker(QueueProcessingWorker):
|
||||||
len(events),
|
len(events),
|
||||||
user_profile_id,
|
user_profile_id,
|
||||||
)
|
)
|
||||||
|
with sentry_sdk.start_span(
|
||||||
|
description="sending missedmessage_emails to user"
|
||||||
|
) as span:
|
||||||
|
span.set_data("user_profile_id", user_profile_id)
|
||||||
|
span.set_data("event_count", len(events))
|
||||||
try:
|
try:
|
||||||
# Because we process events in batches, an
|
# Because we process events in batches, an
|
||||||
# escaped exception here would lead to
|
# escaped exception here would lead to
|
||||||
|
|
Loading…
Reference in New Issue