Skip to content

Commit

Permalink
feat: drop sentry's RQ integration
Browse files Browse the repository at this point in the history
It overrides what we set with information that isn't really useful for us.
Set a more readable method name, and add in some additional job metadata.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit bd6eaab)
  • Loading branch information
akhilnarang authored and mergify[bot] committed Mar 26, 2024
1 parent 731dbfc commit 1eab176
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions frappe/utils/background_jobs.py
Expand Up @@ -22,7 +22,7 @@
import frappe
import frappe.monitor
from frappe import _
from frappe.utils import CallbackManager, cint, cstr, get_bench_id
from frappe.utils import CallbackManager, cint, get_bench_id
from frappe.utils.commands import log
from frappe.utils.deprecations import deprecation_warning
from frappe.utils.redis_queue import RedisQueue
Expand Down Expand Up @@ -130,12 +130,18 @@ def enqueue(
if not timeout:
timeout = get_queues_timeout().get(queue) or 300

# Prepare a more readable name than <function $name at $address>
if isinstance(method, Callable):
method_name = f"{method.__module__}.{method.__qualname__}"
else:
method_name = method

queue_args = {
"site": frappe.local.site,
"user": frappe.session.user,
"method": method,
"method": method_name,
"event": event,
"job_name": job_name or cstr(method),
"job_name": job_name or method_name,
"is_async": is_async,
"kwargs": kwargs,
}
Expand Down Expand Up @@ -606,7 +612,6 @@ def _start_sentry():
from sentry_sdk.integrations.dedupe import DedupeIntegration
from sentry_sdk.integrations.excepthook import ExcepthookIntegration
from sentry_sdk.integrations.modules import ModulesIntegration
from sentry_sdk.integrations.rq import RqIntegration

from frappe.utils.sentry import FrappeIntegration, before_send

Expand All @@ -616,7 +621,6 @@ def _start_sentry():
DedupeIntegration(),
ModulesIntegration(),
ArgvIntegration(),
RqIntegration(),
]

experiments = {}
Expand Down
1 change: 1 addition & 0 deletions frappe/utils/sentry.py
Expand Up @@ -59,6 +59,7 @@ def set_scope(scope):
waitdiff = datetime.utcnow() - job.enqueued_at
context.uuid = job.id
context.wait = waitdiff.total_seconds()
context.kwargs = kwargs

scope.set_extra("job", context)
scope.set_transaction_name(transaction_name)
Expand Down

0 comments on commit 1eab176

Please sign in to comment.