我已将我的 python 默认记录器与 raven 集成。现在我的错误记录在 sentry.io/my_app 上。但我想问一下,有没有什么方法可以为这个产生错误的函数编写单元测试,然后以某种方式确认这个错误在 sentry 上存在。
最佳答案
在 Raven-Python 中你可以实现一个 custom transport将 HTTP 请求换成一个简单的回调。这是通过实现一个抽象类来完成的,不幸的是,该抽象类没有很多文档,而且您获得的数据是 json 编码数据的字节串。您可以在此处找到抽象类:https://github.com/getsentry/raven-python/blob/285b257cf386bfac78f6fe334c9044af65f98561/raven/transport/base.py#L26
这在 the new SDK 中稍微容易一些你可以在哪里写(不提供 DSN):
events = []
init(transport=events.append)
将事件收集到数组中而不是将它们发送到服务器。
关于 python : How can I test that my error has been logged on sentry?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44111487/