The Elastic APM Node.js agent supports source maps by default. If you transpile your source code and supply a source map, the agent will be able to collect the correct stack traces and even the original source code if available.
To take advantage of this, simply make sure that your transpiled source code contains a
It can either point to a source map file on disk:
Or you can inline the source map using base64 encoding:
All modern build toolchains support generating source maps and adding these comments to the transpiled source code.
Original source codeedit
Elastic APM uses source maps for two purposes: to collect stack traces that point to your original source code, and to collect the original source code as inline code snippets related to each frame in your stack traces.
For optimal support,
we recommend that you either inline the original source code using the
sourcesContent property inside the source map,
or that you deploy the original source code to your production server along with the transpiled source code.
If you choose to deploy the original source code,
make sure that it’s accessible via the file system at the path specified with the
sourceRoot property in the source map.
Your source maps or original source code does not need to be available via the internet. Everything is handled by the local Node.js agent on your server.