humanmade / aws-xray

HM Platform AWS X-Ray Integration
23 stars 4 forks source link

Capture Fatal errors #21

Closed nathanielks closed 5 years ago

nathanielks commented 5 years ago

I've noticed that we don't record PHP Fatals in X-Ray at all, so I've been investigating what that would require us do. I see we don't call register_shutdown_function at all, which is how we'd do it as it's always called, Fatal or not. Is this omission intentional or simply not gotten to yet?

nathanielks commented 5 years ago

Hmm, this appears to be inconsistent. I'm testing by requiring a file (that doesn't exist) at the very end of bootstrap() and the Fatal is recorded and sent to x-ray. I seem to recall other fatals I've seen on other stacks that aren't captured, so this is rather confusing behavior as some fatals seem to be captured but others not.

I do notice we require WordPress to be fully up and running in order to register the shutdown function, as well as to register x-ray. I propose having 2 separate bootstrap functions: 1 that bootstraps xhprof and php and a separate one that can hook into WordPress for additional visibility. This would allow us to bootstrap PHP's error handling before WordPress is instantiated and catch fatals that occur before muplugins_loaded.

joehoyle commented 5 years ago

Fixed in https://github.com/humanmade/aws-xray/pull/22