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.

BaseTelemetrySpan

Base class for telemetry spans that defines the common interface and shared functionality.

TelemetrySpan

A telemetry span that assumes a top-level transaction is already in place

TelemetryTransaction

A top-level telemetry transaction span.

MultiTransactionTelemetrySpan

A telemetry span for long-running operations that you do not want to wait to finish before getting any telemetry. Sends an instantaneous transaction at start and stop and at a regular heartbeat interval.

ObjectServiceTelemetrySpan

Data

Data

Description

TELEMETRY_SPAN_OP_DEFAULT

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
tlc.core.utils.telemetry.TELEMETRY_SPAN_OP_DEFAULT = 3lc.telemetry
class tlc.core.utils.telemetry.Telemetry

Telemetry class for 3LC.

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

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

Get the telemetry instance.

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.

static get_sentry_config() tlcsaas.sentry_config.SentryConfiguration
static get_sentry_dashboard_config() dict
property is_enabled: bool
should_capture_messages(is_include_object_service: bool = True) bool
LogLevelStr = None
capture_message(message_text: str, message_tags: dict[str, Any] | None = None, message_extras: dict[str, Any] | None = None, level: LogLevelStr = 'info', include_stack_trace: bool = False) None
capture_instantaneous_span(*, span_name: str, span_op: str = TELEMETRY_SPAN_OP_DEFAULT, span_tags: dict[str, Any] | None = None, span_data: dict[str, Any] | None = None, is_create_transaction_if_none: bool = False) str
capture_instantaneous_transaction_span(*, span_name: str, span_op: str = TELEMETRY_SPAN_OP_DEFAULT, span_tags: dict[str, Any] | None = None, span_data: dict[str, Any] | None = None, trace_id: str = '') str
static get_stack_trace() list[str]
class tlc.core.utils.telemetry.BaseTelemetrySpan(span_name: str, *, is_include_exit_on_error: bool = False, is_include_object_service: bool = False, get_enter_tags: Callable[[], dict[str, Any]] | None = None, get_enter_data: Callable[[], dict[str, Any]] | None = None, get_exit_tags: Callable[[], dict[str, Any]] | None = None, get_exit_data: Callable[[], dict[str, Any]] | None = None)

Bases: abc.ABC

Base class for telemetry spans that defines the common interface and shared functionality.

abstract on_span_start(tags: dict[str, Any], data: dict[str, Any]) None

Called when the span starts. Implementations should set up the telemetry object and record initial state.

abstract on_span_stop(tags: dict[str, Any], data: dict[str, Any]) None

Called when the span stops. Implementations should record final state and clean up the telemetry object.

class tlc.core.utils.telemetry.TelemetrySpan(span_name: str, *, span_op: str = TELEMETRY_SPAN_OP_DEFAULT, is_include_exit_on_error: bool = False, is_include_object_service: bool = False, get_enter_tags: Callable[[], dict[str, Any]] | None = None, get_enter_data: Callable[[], dict[str, Any]] | None = None, get_exit_tags: Callable[[], dict[str, Any]] | None = None, get_exit_data: Callable[[], dict[str, Any]] | None = None)

Bases: tlc.core.utils.telemetry.BaseTelemetrySpan

A telemetry span that assumes a top-level transaction is already in place

create_span() sentry_sdk.tracing.Span
on_span_start(tags: dict[str, Any], data: dict[str, Any]) None
on_span_stop(tags: dict[str, Any], data: dict[str, Any]) None
capture_child_span(span_name: str, span_op: str = TELEMETRY_SPAN_OP_DEFAULT, span_tags: dict[str, Any] | None = None, span_data: dict[str, Any] | None = None) None
class tlc.core.utils.telemetry.TelemetryTransaction(transaction_name: str, *, transaction_op: str = TELEMETRY_SPAN_OP_DEFAULT, is_include_exit_on_error: bool = False, is_include_object_service: bool = False, get_enter_tags: Callable[[], dict[str, Any]] | None = None, get_enter_data: Callable[[], dict[str, Any]] | None = None, get_exit_tags: Callable[[], dict[str, Any]] | None = None, get_exit_data: Callable[[], dict[str, Any]] | None = None)

Bases: tlc.core.utils.telemetry.TelemetrySpan

A top-level telemetry transaction span.

create_span() sentry_sdk.tracing.Span
class tlc.core.utils.telemetry.MultiTransactionTelemetrySpan(span_name: str, *, span_op: str = TELEMETRY_SPAN_OP_DEFAULT, is_include_exit_on_error: bool = False, is_include_object_service: bool = False, get_enter_tags: Callable[[], dict[str, Any]] | None = None, get_enter_data: Callable[[], dict[str, Any]] | None = None, get_exit_tags: Callable[[], dict[str, Any]] | None = None, get_exit_data: Callable[[], dict[str, Any]] | None = None, get_heartbeat_tags: Callable[[], dict[str, Any]] | None = None, get_heartbeat_data: Callable[[], dict[str, Any]] | None = None, heartbeat_interval: datetime.timedelta | None = None, start_message: str | None = None, stop_message: str | None = None, heartbeat_message: str | None = None)

Bases: tlc.core.utils.telemetry.BaseTelemetrySpan

A telemetry span for long-running operations that you do not want to wait to finish before getting any telemetry. Sends an instantaneous transaction at start and stop and at a regular heartbeat interval.

on_span_start(tags: dict[str, Any], data: dict[str, Any]) None
on_span_stop(tags: dict[str, Any], data: dict[str, Any]) None
async consider_heartbeat_message() None

Send a heartbeat message with current state if no interval is specified or if the interval has elapsed.

class tlc.core.utils.telemetry.ObjectServiceTelemetrySpan(*, tui: bool, with_public_examples: bool, ngrok: bool)

Bases: tlc.core.utils.telemetry.MultiTransactionTelemetrySpan