Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: num2words, babel, gettext, sentry imports (backport #26475) #26477

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frappe/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@

# If gc.freeze is done then importing modules before forking allows us to share the memory
if frappe._tune_gc:
import gettext

import babel
import babel.messages
import bleach
import num2words
import pydantic

import frappe.boot
Expand Down
12 changes: 12 additions & 0 deletions frappe/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
bootstrap client session
"""

import os

import frappe
import frappe.defaults
import frappe.desk.desk_page
Expand Down Expand Up @@ -111,6 +113,9 @@ def get_bootinfo():
bootinfo.marketplace_apps = get_marketplace_apps()
bootinfo.changelog_feed = get_changelog_feed_items()

if sentry_dsn := get_sentry_dsn():
bootinfo.sentry_dsn = sentry_dsn

return bootinfo


Expand Down Expand Up @@ -474,3 +479,10 @@ def add_subscription_conf():
return frappe.conf.subscription
except Exception:
return ""


def get_sentry_dsn():
if not frappe.get_system_settings("enable_telemetry"):
return

return os.getenv("FRAPPE_SENTRY_DSN")
1 change: 0 additions & 1 deletion frappe/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@
extend_bootinfo = [
"frappe.utils.telemetry.add_bootinfo",
"frappe.core.doctype.user_permission.user_permission.send_user_permissions",
"frappe.utils.sentry.add_bootinfo",
]

get_changelog_feed = "frappe.desk.doctype.changelog_feed.changelog_feed.get_feed"
Expand Down
10 changes: 0 additions & 10 deletions frappe/utils/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,3 @@ def capture_exception(message: str | None = None) -> None:

except Exception:
frappe.logger().error("Failed to capture exception", exc_info=True)
pass


def add_bootinfo(bootinfo):
"""Called from hook, sends DSN so client side can setup error monitoring."""
if not frappe.get_system_settings("enable_telemetry"):
return

if sentry_dsn := os.getenv("FRAPPE_SENTRY_DSN"):
bootinfo.sentry_dsn = sentry_dsn
Loading