Skip to content

Commit

Permalink
fix: added sentry at exit flush
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbraun89 authored May 28, 2023
1 parent 23c1b20 commit 7714abb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nanolayer/utils/analytics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging
import os
import platform
import sys

import sentry_sdk
from sentry_sdk.integrations.atexit import AtexitIntegration

from nanolayer.utils.linux_information_desk import EnvFile, ProcFile
from nanolayer.utils.settings import NanolayerSettings
Expand All @@ -11,6 +13,10 @@
logger = logging.getLogger(__name__)


def at_exit_callback(pending: int, timeout: int) -> None:
sys.stderr.flush()


def setup_analytics() -> None:
try:
dsn = (
Expand All @@ -30,6 +36,7 @@ def setup_analytics() -> None:
MemoryError, # machine is running out of memory
NotImplementedError, # user is using a feature that is not implemented
],
integrations=[AtexitIntegration(callback=at_exit_callback)],
release=resolve_own_package_version(),
traces_sample_rate=1.0,
dsn=dsn,
Expand Down

0 comments on commit 7714abb

Please sign in to comment.