Skip to main content

Python telemetry

Use tiden-telemetry for Python applications.

Install

pip install tiden-telemetry

Requires Python 3.9 or newer.

Initialize

import os
import tiden_telemetry as tiden

tiden.init(
dsn=os.environ["TIDEN_DSN"],
release="my-app@1.2.3",
environment="production",
)

The SDK installs sys.excepthook and threading.excepthook by default.

Capture exceptions

Inside an except block:

try:
do_work()
except Exception:
tiden.capture_exception()

Capture a message:

tiden.capture_message("checkout completed", "info")

WSGI middleware

from tiden_telemetry.wsgi import TidenWsgiMiddleware

application = TidenWsgiMiddleware(application)

The middleware captures unhandled exceptions and re-raises them.

Logging handler

import logging
from tiden_telemetry.logging import TidenLoggingHandler

logging.getLogger().addHandler(TidenLoggingHandler())

Use logger.exception(...) to send exception logs to Tiden.

Context

tiden.set_tag("plan", "pro")
tiden.set_user({"id": "u_123"})