Python中带有loggingIntegration的Sentry没有观察到event_level=logging.CRITICAL

问题描述 投票:0回答:1

我有一个 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
时,不会发生此问题它仅发生在从主模块调用的子模块中。

python exception logging sentry
1个回答
0
投票
我是 Sentry 的 PM,来自我们的 python SDK 团队,刚刚查看了此内容,但无法重现,您的设置应该可以工作。如果您可以在我们的存储库上创建问题并提供复制存储库或更多信息,我们可以尽力提供帮助。

https://github.com/getsentry/sentry-python/issues

© www.soinside.com 2019 - 2024. All rights reserved.