我有一个 python 脚本,可以像这样初始化哨兵:
def sentry_init():
sentry_sdk.init(
'some dsn',
traces_sample_rate=1.0,
environment='staging',
integrations=[
LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.CRITICAL, # Send records as events
),
],
)
def foo():
# calls functions from another script which also logs
if __name__ == "__main__":
sentry_init()
logging.basicConfig(level='INFO')
log = logging.getLogger('foo')
log.addHandler(HttpApiHandler())
foo()
在另一个名为
modb
的模块中,它具有从 foo()
调用的函数,我还使用 log = logging.getLogger(__name__)
进行日志记录设置
# modb
import logging
log = logging.getLogger(__name__)
def modfunc():
try:
if:
# Some conditions
else:
raise Exception("Some error")
except Exception as e:
log.error(str(e))
so
modb
有一个包罗万象的东西,通过记录 ERROR
来处理。但我看到这个ERROR
已登录哨兵。如果我将哨兵初始化为仅记录CRITICAL
或以上,这怎么可能?
当从主模块中抛出
ERROR
时,不会发生此问题它仅发生在从主模块调用的子模块中。