swh.core.sentry module#

swh.core.sentry.get_sentry_release(main_package: str | None = None, sentry_dsn: str | None = None)[source]#
swh.core.sentry.override_with_bool_envvar(envvar: str, default: bool) bool[source]#

Override the default with the environment variable envvar parsed as a boolean

swh.core.sentry.override_with_float_envvar(envvar: str, default: float | None) float | None[source]#

Override default with the environment variable envvar casted as a float.

default is returned if the environment variable envvar is missing or if we’re not able to cast it to a float.

Parameters:
  • envvar – the name of the environment variable

  • default – default value

Returns:

A float or default

swh.core.sentry.init_sentry(sentry_dsn: str | None = None, *, main_package: str | None = None, environment: str | None = None, debug: bool = False, disable_logging_events: bool = False, integrations: List | None = None, traces_sample_rate: float | None = None, extra_kwargs: Dict | None = None, deferred_init: bool = False) None[source]#

Configure the sentry integration.

Parameters:
  • sentry_dsn – Sentry DSN; where sentry report will be sent. Overridden by SWH_SENTRY_DSN

  • main_package – Full name of main Python package associated to Sentry DSN. Overridden by SWH_MAIN_PACKAGE.

  • environment – Sentry environment. Overridden by SWH_SENTRY_ENVIRONMENT

  • debug – turn on Sentry SDK debug mode. Overridden by SWH_SENTRY_DEBUG

  • disable_logging_events – if set, disable the automatic reporting of error/exception log entries as Sentry events. Overridden by SWH_SENTRY_DISABLE_LOGGING_EVENTS

  • integrations – list of dedicated Sentry integrations to include

  • traces_sample_rate – a number between 0 and 1, controlling the percentage chance a given transaction will be sent to Sentry. Overridden by SWH_SENTRY_TRACES_SAMPLE_RATE

  • extra_kwargs – dict of additional parameters passed to sentry_sdk.init()

  • deferred_init – indicates that sentry will be properly initialized in subsequent calls and that no warnings about missing DSN should be logged