Skip to content

Commit 7714abb

Browse files
fix: added sentry at exit flush
1 parent 23c1b20 commit 7714abb

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

nanolayer/utils/analytics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import logging
22
import os
33
import platform
4+
import sys
45

56
import sentry_sdk
7+
from sentry_sdk.integrations.atexit import AtexitIntegration
68

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

1315

16+
def at_exit_callback(pending: int, timeout: int) -> None:
17+
sys.stderr.flush()
18+
19+
1420
def setup_analytics() -> None:
1521
try:
1622
dsn = (
@@ -30,6 +36,7 @@ def setup_analytics() -> None:
3036
MemoryError, # machine is running out of memory
3137
NotImplementedError, # user is using a feature that is not implemented
3238
],
39+
integrations=[AtexitIntegration(callback=at_exit_callback)],
3340
release=resolve_own_package_version(),
3441
traces_sample_rate=1.0,
3542
dsn=dsn,

0 commit comments

Comments
 (0)