Source Mapsedit

For a number of reasons, it is common practice to minify JavaScript code, for example to reduce network latency. While improving performance, minified code can be hard to debug. A source map library helps by mapping the minified files back to the the original source code.

APM Server provides a Source Map API for uploading source maps.

By default, source_mapping.enabled is set to true. This means if a source map has previously been uploaded, source mapping will automatically be applied all incoming transactions and errors.

Source maps are cached in memory for as long as the cache expiration setting indicates.

How source maps are appliededit

APM Server needs to find the correct source map for every stack trace frame in an event. To do so, it tries the following:

  • Compare the event’s service.name with the source map’s service_name
  • Compare the event’s service.version with the source map’s service_version
  • Compare the stack trace frame’s abs_path with the source map’s bundle_filepath

If a source map is found, the following attributes in the stack trace frames are overwritten:

  • filename
  • function
  • line number
  • column number
  • abs path is cleaned to be the shortest path name equivalent to the given path name.

If multiple source maps are found, the one with the latest upload timestamp is used.

See what an example source map looks like in Elasticsearch.