From 7714abbd1e554d709180a499d50d5f9d3dfd44ef Mon Sep 17 00:00:00 2001 From: Daniel Braun Date: Sun, 28 May 2023 10:52:39 +0000 Subject: [PATCH] fix: added sentry at exit flush --- nanolayer/utils/analytics.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nanolayer/utils/analytics.py b/nanolayer/utils/analytics.py index bcd8325f..2c4b91aa 100644 --- a/nanolayer/utils/analytics.py +++ b/nanolayer/utils/analytics.py @@ -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 @@ -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 = ( @@ -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,