我目前正在尝试为Symfony项目(PHP)实现GCP错误报告,以便报告任何错误,尤其是应用程序的堆栈跟踪。该实现是通过使用Google Cloud Client Library完成的。但是,看来GCP没有检测到我正在发送的stacktrace。以下是界面上的屏幕截图:如本文档中所述。我必须精确确定要发送给ReportedEventError的消息的类型(如果我没有记错的话,消息应该以'PHP Fatal Error'开头)字符串,以便将该消息识别为堆栈跟踪。但这没有用。
为了帮助您解决以下问题,以下是Google Cloud Client Library发送的JSON酬劳。
"insertId": "INSERT ID ",
"jsonPayload": {
"context": {
"httpRequest": {
"responseStatusCode": 500,
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
"method": "GET",
"url": "/ping/edit",
"remoteIp": "172.18.0.1"
},
"reportLocation": {
"functionName": "editAction",
"filePath": "/app/src/NS/PingBundle/Controller/DefaultController.php",
"lineNumber": 24
}
},
"message": "PHP Fatal error: #0 [internal function]: NS\\CommonBundle\\EventListener\\ExceptionListener->onKernelException(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent), 'kernel.exceptio...', Object(Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher))\n#1 /app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php(104): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent), 'kernel.exceptio...', Object(Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher))\n#2 [internal function]: Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener->__invoke(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent), 'kernel.exceptio...', Object(Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#3 /app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php(212): call_user_func(Object(Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener), Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent), 'kernel.exceptio...', Object(Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#4 /app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php(44): Symfony\\Component\\EventDispatcher\\EventDispatcher->doDispatch(Array, 'kernel.exceptio...', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent))\n#5 /app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php(146): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch('kernel.exceptio...', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent))\n#6 /app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(230): Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher->dispatch('kernel.exceptio...', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent))\n#7 /app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(79): Symfony\\Component\\HttpKernel\\HttpKernel->handleException(Object(Exception), Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#8 /app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(171): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#9 /app/web/app_dev.php(28): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#10 {main}",
"serviceContext": {
"service": "hummingbird-sf"
},
"@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent"
},
"httpRequest": {
"requestMethod": "GET",
"requestUrl": "/ping/edit",
"status": 500,
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
"remoteIp": "172.18.0.1"
},
"resource": {
"type": "reported_errors",
"labels": {
"project_id": "<project_id>"
}
},
"timestamp": "2019-12-09T14:33:51.792619820Z",
"severity": "ERROR",
"logName": "projects/<project_id>/logs/clouderrorreporting.googleapis.com%2Freported_errors",
"sourceLocation": {
"file": "/app/src/NS/PingBundle/Controller/DefaultController.php",
"line": "24",
"function": "editAction"
},
"receiveTimestamp": "2019-12-09T14:33:51.792619820Z"
}
注意:我也尝试删除也不起作用的位置。至于Symfony框架集成,由于其他原因,该解决方案也不起作用。
有人有什么想法吗?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。