删除哨兵中的当前面包屑
remove current breadcrumbs in sentry
我有这样简单的同步代码:
import sentry_sdk
from time import sleep
sentry_sdk.init(MY_DSN)
while True:
# remove sentry breadcrumbs here, so they would not accumulate
try:
do_my_stuff()
except:
handle_my_exception()
sleep(some_non_linear_algorithm()) # I would like not to use crontab
当异常发生时,sentry 会捕获它以及之前迭代中的所有面包屑,因此我需要在每次迭代开始时删除所有当前面包屑。但是我在哨兵文档中找不到任何 API 来做到这一点。
将您的代码包装成这样:
with sentry_sdk.push_scope():
try:
...
except:
...
这将确保您不会在迭代之间泄露面包屑、标签等。
或者您可以使用:
with sentry_sdk.configure_scope() as scope:
scope.clear()
我有这样简单的同步代码:
import sentry_sdk
from time import sleep
sentry_sdk.init(MY_DSN)
while True:
# remove sentry breadcrumbs here, so they would not accumulate
try:
do_my_stuff()
except:
handle_my_exception()
sleep(some_non_linear_algorithm()) # I would like not to use crontab
当异常发生时,sentry 会捕获它以及之前迭代中的所有面包屑,因此我需要在每次迭代开始时删除所有当前面包屑。但是我在哨兵文档中找不到任何 API 来做到这一点。
将您的代码包装成这样:
with sentry_sdk.push_scope():
try:
...
except:
...
这将确保您不会在迭代之间泄露面包屑、标签等。
或者您可以使用:
with sentry_sdk.configure_scope() as scope:
scope.clear()