tlc.core.utils.telemetry#

Module Contents#

Classes#

Class

Description

JupyterExcepthookIntegration

Hook into Jupyter’s excepthook to capture unhandled exceptions so that they get reported to Sentry.

Telemetry

Telemetry class for 3LC.

RunningMessage

API#

class tlc.core.utils.telemetry.JupyterExcepthookIntegration#

Bases: sentry_sdk.integrations.Integration

Hook into Jupyter’s excepthook to capture unhandled exceptions so that they get reported to Sentry.

identifier = jupyter_excepthook#
static setup_once() None#
class tlc.core.utils.telemetry.Telemetry#

Telemetry class for 3LC.

This class is responsible for initializing the telemetry system for 3LC.

Initialize the telemetry system.

telemetry_instance: tlc.core.utils.telemetry.Telemetry | None = None#
static instance() tlc.core.utils.telemetry.Telemetry#

Get the telemetry instance.

static try_derive_user_id(event: dict | None) None#
static consider_scrub_url(url: str) str#

Remove sensitive information from the URL.

static scrub_urls(event: dict | None) dict | None#
static filter_urls(event: dict | None) dict | None#
static before_send_transaction(event: dict | None, hint: dict) dict | None#

Remove sensitive information from the URL.

static before_send(event: dict[str, Any], hint: dict[str, Any]) dict[str, Any] | None#

Filter out exceptions that should not be sent to Sentry.

These are:

  1. HTTPExceptions as these are handled errors in Starlite.

  2. Exceptions that do not include tlc in the stacktrace. E.g. if the users has imported tlc in a notebook and triggers unrelated errors.

  3. Some critical log messages we know happen during testing.

static get_sentry_environment() str#

Get the Sentry environment.

This method uses various heuristics to determine the environment in which the code is running.

  1. If the TLC_SENTRY_ENVIRONMENT environment variable is set, it will take precedence over the other logic.

  2. If the tlc module is installed from a wheel, the environment will be set to “production”.

  3. If neither of these are set, we will assume that we are running from a development environment.

Returns:

The Sentry environment. By convention this will be one of “production”, “testing”, “staging”, or “development”.

static get_sentry_dashboard_config() dict#
class tlc.core.utils.telemetry.RunningMessage(start_time: datetime.datetime)#
async consider_message() None#