Description
I am having trouble figuring out how to get elastic apm working with a hybrid express + nextjs app in an effective way.
It seems to pick up requests fine (to specific URLs) and it also picks up error codes and they show up in the elastic UI "transactions" tab.
But I cant seem to get errors to show up in the "errors" tab.
If i throw an error in a next page
- eg: ~/page/test.js
Say I have:
function Test() {
throw new Error('Blah');
return (
<p>
Hello World
</p>
)
}
export default Test
It does not show up in the elastic UI.
Describe the solution you'd like
I need exceptions that occur in nextjs to show up in the "error" tab in the elastic apm UI.
A hybrid express + nextjs app would look like this as an example:
https://github.com/jooj123/test-nextjs
Describe alternatives you've considered
I have tired to send errors manually in the next page, via captureError
:
https://www.elastic.co/guide/en/apm/agent/nodejs/3.x/agent-api.html#apm-capture-error
But then i get a compile error like:
./node_modules/elastic-apm-node/lib/instrumentation/async-hooks.js
Module not found: Can't resolve 'async_hooks' in '/Users/martin.jujou/Documents/projects/fe-server-auction-results/node_modules/elastic-apm-node/lib/instrumentation'
> Build error occurred
Error: > Build failed because of webpack errors
This I believe is because nextjs pages are built for client and server and because elastic apm is a node client it blows up with the async_hooks error, much like:
vercel/next.js#4348
Not sure if you have any suggestions ...
For any exceptions at the express side of things i'm ok, but if an exception occurs in nextjs context im blind at the moment which is far from ideal