1

With a PHP application in Google App Engine, I cannot get the errors to show in the Error Reporting view, part of the Stackdriver offering. It should be configured by default, but putting in errors on purpose or by logging with error_log() still leaves the Error Reporting view empty.

The errors do show up in the Logging view as request with an error in the request_log.

Do I need to configure something? The docs say this should work by default (and as far as I can tell I am not using the Flexible Environment).

Kirk Kelsey
  • 4,259
  • 1
  • 23
  • 26
Whiskey
  • 262
  • 3
  • 15
  • Hi, I am the Stackdriver Error Reporting product manager. Indeed, PHP application on App Engine standard should work out of the box, providing that errors appear in your application logs. Could you confirm that you see the errors with stack traces in the logs? – Steren Aug 18 '16 at 11:20
  • 1
    Hi Steren, thanks for following up. I get the errors in the "request log" (the only other that I can select is "activity"), but only with a line number, not a complete stack trace. For example PHP Fatal error: Class 'NumberFormatter' not found in /base/data/home/apps/e~xyz/1.394995078782036923/Public/Models/Group.php on line 833 I had also submitted a support request for this and have sent a HAR file this morning at their request. – Whiskey Aug 18 '16 at 20:02

2 Answers2

3

Error Reporting is configured out of the box for App Engine standard PHP, no setup is required.

But it seems that the error parser has an issue and does not detect your errors, in particular errors of the shape: <type>: <message> in <file> on line <line>. It expects <type>: <message> in <file>:<line>.

We will be working on a fix in the following weeks. Thanks for your feedback. UPDATE: The fix for this particular problem has been deployed.

Steren Giannini, Stackdriver Error Reporting product manager

Steren
  • 7,311
  • 3
  • 31
  • 51
  • Thanks for looking into this! – Whiskey Aug 19 '16 at 16:59
  • 1
    @Steren, I notice that this is still not fixed and that the format seems to have changed. The API and Stackdriver-logging-powered entrypoints give no indication of failure. It just only works when the magic undocumented format is used. Is there some documentation on what can be given here because without any proper error context, this whole product is largely useless to me, especially if there is POST data involved. – nathanjosiah Aug 31 '16 at 06:29
  • Understand that we need some time to fix the problem, it is a matter of weeks (but not days). Which undocumented format are you referring to? We do not document the stack traces format but we document the structured payload to use with the API or with Stackdriver Logging: https://cloud.google.com/error-reporting/docs/formatting-error-messages – Steren Aug 31 '16 at 06:59
  • I understand, it has been nearly 2 weeks since that message. Anyway, the only format that lets the error show up from what testing I've done is "\n at ::". Any other format, including anything with more than the 2 lines described, does not show up in the logging. – nathanjosiah Aug 31 '16 at 15:01
  • @Steren Also, for debugging application code, it would be very helpful to be able to see the details of the request that caused the error such as POST data. Is there any way to add more details other than the message and the filename? – nathanjosiah Aug 31 '16 at 15:23
  • @Steren I want to add that as long as the first two lines match the format I described, all the lines after can be something else but it isn't parsed correctly. – nathanjosiah Sep 02 '16 at 19:15
  • When you say 'does not show up in the logging', are you saying that you do not see your stack traces in Stackdriver Logging? To help us debug, could you paste here an example of a stack trace that is in your GAE logs, but does not appear in Error Reporting? Thanks – Steren Sep 06 '16 at 08:08
  • I am not using GAE but rather the error reporting service and have documented the relevant portions in this gist: https://gist.github.com/nathanjosiah/4f2c7677b791033c08ddb1001029a0ac – nathanjosiah Sep 06 '16 at 16:36
  • @Steren - I've been experiencing the exact same issue with php on GAE. I see the errors in the Logger, but if I go to Error Reporting (where I should be able to setup notifications), I see 0 errors. – flynn Sep 06 '16 at 17:34
  • 1
    Thanks a lot for the detailed report. We are now working on fixing the problem. – Steren Sep 06 '16 at 17:58
  • any updates on this @steren ? This is pretty critical to us and the fallout from it not working is hurting us pretty bad. it's been a month and 2 weeks since the last activity on this thread. – flynn Sep 19 '16 at 17:36
  • @Steren I found PHP Exception is represented as object sometimes and string in other times (shown in stackdriver logging), do you have any recommendation to get Exception as object for all PHP Exceptions? (I prefer use Exception object instead of string, because object has more information, even though there are a lot of Exceptions represented by string in logs) – Yao Li Feb 26 '18 at 18:00
0

Stackdriver Error Reporting is configured out of the box for PHP App Engine applications.

We just released a fix for our PHP stack trace parser last week. We should now be able to process the frames that I describe in my original answer. Can you let me know if everything is OK for you ?

Steren
  • 7,311
  • 3
  • 31
  • 51
  • It kinda works: A PHP Fatal error will show up in the error reporting now. That is great. – Whiskey Sep 20 '16 at 16:26
  • However, errors generated with error_log() do not show, even though the meta data in the log request classifies it as ERROR. Probably because you are parsing the actual response and not the metadata? And PHP warnings are also not included, but that is according to spec. However, that does make the error view fairly useless as PHP classifies many errors as warnings even though these can still break the application, for example an error in a SQL statement or undefined variable. Any chance of improving the error logging to include that? – Whiskey Sep 20 '16 at 16:34
  • 1
    Thanks for the feedback. We released a fix to the original problem of parsing `: in on line `. We will look into being more flexible with PHP errors in the future. – Steren Sep 21 '16 at 08:47
  • 1
    @Steren At some point since this fix, the undocumented magic format changed again and all of our reporting stopped working. This service is nearly useless to us when the service stops logging when the magic format changes. It would be far more useful if the service would log everything no matter what but only give pretty displays if it can parse the message. Do you have an alternative service that you would reccomend that will just log all errors? – nathanjosiah Dec 20 '16 at 19:27
  • If Stackdriver is not able to parse the stack trace, then no grouping is possible. I would say that Stackdriver Logging is a good place to store all errors. You can also monitor the total number of errors in the App Engine dashboard or Stackdriver Monitoring. – Steren Dec 20 '16 at 19:54
  • @Steren Will there be documentation as to the supported formats so that we can utilize this service? – nathanjosiah Dec 20 '16 at 20:54
  • Yes, we are working on better documentation for the exact format, I'll try to ping this thread once it's out. For PHP, we currently require the following format: Must start with `PHP (Notice|Parse error|Fatal error|Warning)` and contain the result of [`(string)$exception`](http://php.net/manual/en/exception.tostring.php) We know that this is too limitating and are working to make our PHP parser more flexible (removing the prefix constraint) – Steren Dec 21 '16 at 13:11