Source Maps

edit

It is common practice to minify JavaScript code, for example to reduce network latency. While improving performance, minified code is also hard to debug. A source map library helps by mapping the minified files back the the original source code.

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

Source maps are then automatically applied to all incoming transactions and errors.

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

How source maps are applied

edit

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 how an example source map looks like in Elasticsearch.