Stackdriver Logging没有正确处理Google Cloud Function中的python quit(代码)堆栈跟踪,还有其他选择吗?

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

我有一个用python37编写的google云功能,在某些情况下我记录错误(使用日志记录)然后使用quit(代码)来结束函数执行。在stackdriver中正确记录错误日志记录。问题是stackdriver如何处理quit()。它将记录stacktrace中的每一行作为日志条目进行处理,如捕获中所示。当我使用sys.exit(代码)或引发SystemExit(代码)时,会发生同样的事情。最后,云函数以0退出,就好像没有错误一样。任何人都有一个替代方案可以在出错后停止云功能吗?那么关于stackdriver行为的任何解释都会很棒。

谢谢!

enter image description here

google-cloud-functions stackdriver python-3.7 google-cloud-stackdriver
1个回答
0
投票

感谢这条推文,我解决了这个问题:多么幸运! https://twitter.com/iamdevloper/status/1060067235316809729

解决方案在这里的文档:https://cloud.google.com/functions/docs/monitoring/error-reporting

并使用:raise RuntimeError('我失败了你')解决了我的问题。非常好的教训和提醒:)

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