PHP exception detector is too strict
Closed this issue · 2 comments
As we can read on https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions/blob/master/lib/fluent/plugin/exception_detector.rb
The rule to detect a PHP exception is:
rule(:start_state, /PHP (?:Notice|Parse error|Fatal error|Warning):/,
:php_stack_begin),
rule(:php_stack_begin, /^Stack trace:/, :php_stack_frames),
rule(:php_stack_frames, /^#\d/, :php_stack_frames),
rule(:php_stack_frames, /^\s+thrown in /, :start_state)
This is too strict. It is indeed valid on App Engine standard, but on another environment, the exceptions are not formatted this way:
On my local machine, I run the following code:
<?php
function func1() {
throw new Exception('Custom exception');
};
function func2() {
func1();
};
try {
func2();
} catch (Exception $e) {
print (string)$e;
}
?>
Here is the output:
exception 'Exception' with message 'Custom exception' in /Users/steren/work/test-php/test.php:5
Stack trace:
#0 /Users/steren/work/test-php/test.php(9): func1()
#1 /Users/steren/work/test-php/test.php(13): func2()
#2 {main}
As you see, it does not start with PHP Fatal Error
and the last line is not thrown in
Because this plugin is intended to be used on Compute Engine, the PHP stacktrace detection should be compatible with the default way to print exception in PHP.
Hi @thomasschickinger, looks like this has been fixed and released. Are we good to close the ticket?
Yes, let's close it. Thanks.