sluijmermultimedia
1 week ago

Laravel + Datadog APM: ddtrace.request_init_hook has run [Failed]

Posted 1 week ago by sluijmermultimedia

Hi everyone,

Our team and I are currently working on a Laravel API for the backend of our application. We have enabled Datadog APM with our server hosting provider a short while ago to trace our PHP code and find slow parts for us to take another look at.

Now Datadog's APM is supposed to work out of the box with frameworks like Laravel, since it simply hooks into the PHP runtime and wraps functions there. For us, however, this did not work out of the box. Some troubleshooting on our hosting provider's side of things showed that the error causing this issue is ddtrace.request_init_hook has run [Failed]. They tested a workaround by adding require_once(ini_get('ddtrace.request_init_hook')); to the top of a phpinfo test file, which worked and enabled tracing. Adding this to our Laravel index.php did not enable the tracing, though. Our hosting provider said that this could be because the Laravel index.php only points towards other code, and that we may have to add the require_once(ini_get('ddtrace.request_init_hook')); line to other PHP files as well. Doing this would result in very messy code, though, as we'd have to add it to hundreds of files.

If anyone knows how we can make sure that Laravel can run the ddtrace.request_init_hook, that would be much appreciated!

Please sign in or create an account to participate in this conversation.