Streamlit + VectorBT dashboard, Parquet harvester with nightly cron, Authentik header auth, SQLite strategy persistence, and Bugsink telemetry. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1 KiB
Python
43 lines
1 KiB
Python
"""Bugsink telemetry via Sentry-compatible SDK."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import os
|
|
|
|
_initialized = False
|
|
|
|
|
|
def init_telemetry(service_name: str) -> None:
|
|
global _initialized
|
|
if _initialized:
|
|
return
|
|
|
|
dsn = os.environ.get("BUGSINK_DSN", "").strip()
|
|
if not dsn:
|
|
logging.getLogger(__name__).info(
|
|
"BUGSINK_DSN not set; telemetry disabled for %s", service_name
|
|
)
|
|
_initialized = True
|
|
return
|
|
|
|
import sentry_sdk
|
|
|
|
sentry_sdk.init(
|
|
dsn=dsn,
|
|
environment=os.environ.get("APP_ENV", "production"),
|
|
release=os.environ.get("APP_RELEASE", "quant-web@1.0.0"),
|
|
traces_sample_rate=0,
|
|
send_client_reports=False,
|
|
auto_session_tracking=False,
|
|
)
|
|
sentry_sdk.set_tag("service", service_name)
|
|
_initialized = True
|
|
|
|
|
|
def capture_exception(exc: BaseException) -> None:
|
|
if not os.environ.get("BUGSINK_DSN", "").strip():
|
|
return
|
|
import sentry_sdk
|
|
|
|
sentry_sdk.capture_exception(exc)
|