mirror of https://github.com/zulip/zulip.git
worker: Address sentry_sdk deprecations.
https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring https://github.com/getsentry/sentry-python/releases/2.0.0 https://github.com/getsentry/sentry-python/releases/2.15.0 Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
08db41660a
commit
ac2b1cd45d
|
@ -9,10 +9,10 @@ from contextlib import contextmanager
|
|||
from types import FrameType
|
||||
from typing import Any
|
||||
|
||||
import sentry_sdk
|
||||
from django.conf import settings
|
||||
from django.core.management.base import CommandError
|
||||
from django.utils import autoreload
|
||||
from sentry_sdk import configure_scope
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.lib.management import ZulipBaseCommand
|
||||
|
@ -104,7 +104,7 @@ class Command(ZulipBaseCommand):
|
|||
logger.info("Worker %d connecting to queue %s", worker_num, queue_name)
|
||||
with log_and_exit_if_exception(logger, queue_name, threaded=False):
|
||||
worker = get_worker(queue_name, worker_num=worker_num)
|
||||
with configure_scope() as scope:
|
||||
with sentry_sdk.isolation_scope() as scope:
|
||||
scope.set_tag("queue_worker", queue_name)
|
||||
scope.set_tag("worker_num", worker_num)
|
||||
|
||||
|
@ -124,7 +124,7 @@ class ThreadedWorker(threading.Thread):
|
|||
@override
|
||||
def run(self) -> None:
|
||||
with (
|
||||
configure_scope() as scope,
|
||||
sentry_sdk.isolation_scope() as scope,
|
||||
log_and_exit_if_exception(self.logger, self.queue_name, threaded=True),
|
||||
):
|
||||
scope.set_tag("queue_worker", self.queue_name)
|
||||
|
|
|
@ -212,7 +212,7 @@ class QueueProcessingWorker(ABC):
|
|||
flush_per_request_caches()
|
||||
reset_queries()
|
||||
|
||||
with sentry_sdk.start_span(description="statistics"):
|
||||
with sentry_sdk.start_span(name="statistics"):
|
||||
if consume_time_seconds is not None:
|
||||
self.recent_consume_times.append((len(events), consume_time_seconds))
|
||||
|
||||
|
@ -252,7 +252,7 @@ class QueueProcessingWorker(ABC):
|
|||
# is needed and the worker can proceed.
|
||||
return
|
||||
|
||||
with sentry_sdk.configure_scope() as scope:
|
||||
with sentry_sdk.new_scope() as scope:
|
||||
scope.set_context(
|
||||
"events",
|
||||
{
|
||||
|
@ -261,9 +261,8 @@ class QueueProcessingWorker(ABC):
|
|||
},
|
||||
)
|
||||
if isinstance(exception, WorkerTimeoutError):
|
||||
with sentry_sdk.push_scope() as scope:
|
||||
scope.fingerprint = ["worker-timeout", self.queue_name]
|
||||
logging.exception(exception, stack_info=True)
|
||||
scope.fingerprint = ["worker-timeout", self.queue_name]
|
||||
logging.exception(exception, stack_info=True)
|
||||
else:
|
||||
logging.exception(
|
||||
"Problem handling data on queue %s", self.queue_name, stack_info=True
|
||||
|
|
|
@ -197,7 +197,7 @@ class MissedMessageWorker(QueueProcessingWorker):
|
|||
# re-checking the condition.
|
||||
return False
|
||||
|
||||
with sentry_sdk.start_span(description="condvar wait") as span:
|
||||
with sentry_sdk.start_span(name="condvar wait") as span:
|
||||
span.set_data("timeout", timeout)
|
||||
was_notified = self.cv.wait_for(wait_condition, timeout=timeout)
|
||||
span.set_data("was_notified", was_notified)
|
||||
|
@ -236,9 +236,7 @@ class MissedMessageWorker(QueueProcessingWorker):
|
|||
len(events),
|
||||
user_profile_id,
|
||||
)
|
||||
with sentry_sdk.start_span(
|
||||
description="sending missedmessage_emails to user"
|
||||
) as span:
|
||||
with sentry_sdk.start_span(name="sending missedmessage_emails to user") as span:
|
||||
span.set_data("user_profile_id", user_profile_id)
|
||||
span.set_data("event_count", len(events))
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue