Skip to content

Commit

Permalink
chore: allow configuring sentry to keep connections alive
Browse files Browse the repository at this point in the history
To avoid spurious missed check-in issues with Sentry Crons for Celery.
  • Loading branch information
michael-smt committed Jul 23, 2024
1 parent ba885aa commit 56d4d03
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/admin/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,15 @@ Configures environment for Sentry. Defaults to ``devel``.

.. setting:: SENTRY_PROFILES_SAMPLE_RATE

SENTRY_KEEP_ALIVE
-----------------

Configures Sentry to keep the connection alive between requests. Defaults to ``False``.

.. seealso::

`Sentry Basic Options <https://docs.sentry.io/platforms/python/configuration/options/>`_

SENTRY_PROFILES_SAMPLE_RATE
---------------------------

Expand Down
4 changes: 4 additions & 0 deletions docs/admin/install/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,10 @@ To enable support for Sentry, set following:

Your Sentry Environment (optional), defaults to :envvar:`WEBLATE_SITE_DOMAIN`.

.. envvar:: SENTRY_KEEP_ALIVE

Configures :setting:`SENTRY_KEEP_ALIVE`.

.. envvar:: SENTRY_TRACES_SAMPLE_RATE

Configures :setting:`SENTRY_TRACES_SAMPLE_RATE`.
Expand Down
1 change: 1 addition & 0 deletions weblate/settings_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@
GOOGLE_ANALYTICS_ID = get_env_str("WEBLATE_GOOGLE_ANALYTICS_ID")
SENTRY_DSN = get_env_str("SENTRY_DSN")
SENTRY_ENVIRONMENT = get_env_str("SENTRY_ENVIRONMENT", SITE_DOMAIN)
SENTRY_KEEP_ALIVE = get_env_bool("SENTRY_KEEP_ALIVE", False)
SENTRY_TRACES_SAMPLE_RATE = get_env_float("SENTRY_TRACES_SAMPLE_RATE")
SENTRY_PROFILES_SAMPLE_RATE = get_env_float("SENTRY_PROFILES_SAMPLE_RATE", 1.0)
SENTRY_TOKEN = get_env_str("SENTRY_TOKEN")
Expand Down
1 change: 1 addition & 0 deletions weblate/utils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def init_error_collection(celery=False) -> None:
],
attach_stacktrace=True,
_experiments={"max_spans": 2000},
keep_alive=settings.SENTRY_KEEP_ALIVE,
**settings.SENTRY_EXTRA_ARGS,
)
# Ignore Weblate logging, those should trigger proper errors
Expand Down
1 change: 1 addition & 0 deletions weblate/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class WeblateConf(AppConf):
SENTRY_EXTRA_ARGS = {}
SENTRY_TRACES_SAMPLE_RATE = 0
SENTRY_PROFILES_SAMPLE_RATE = 0
SENTRY_KEEP_ALIVE = False

CELERY_TASK_ALWAYS_EAGER = True
CELERY_BROKER_URL = "memory://"
Expand Down

0 comments on commit 56d4d03

Please sign in to comment.