The APM Insight PHP Agent is designed to capture the errors that occur within your PHP application. Though the agent does well in capturing application-level errors, it may not report web server-originated errors like 502 Bad Gateway unless they are appropriately handled and propagated within your application code.
For issues related to errors outside your application code, it is better to investigate the root cause at the web server level logs.