- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
If your front-end JavaScript source code is minified, upload your source maps to Datadog to de-obfuscate your different stack traces. For any given error, you can access the file path, line number, and code snippet for each frame of the related stack trace. Datadog can also link stack frames to your source code in your repository.
Configure your JavaScript bundler such that when minifying your source code, it generates source maps that directly include the related source code in the sourcesContent
attribute.
Ensure that the size of each source map augmented with the size of the related minified file does not exceed the limit of 300 MB.
Ensure that the size of each source map augmented with the size of the related minified file does not exceed the limit of 50 MB.
See the following configurations for popular JavaScript bundlers.
You can generate source maps by using the built-in webpack plugin named SourceMapDevToolPlugin.
See the example configuration in your webpack.config.js
file:
// ...
const webpack = require('webpack');
module.exports = {
mode: 'production',
devtool: false,
plugins: [
new webpack.SourceMapDevToolPlugin({
noSources: false,
filename: '[file].map'
}),
// ...
],
optimization: {
minimize: true,
// ...
},
// ...
};
Note: If you are using TypeScript, set compilerOptions.sourceMap
to true
in your tsconfig.json
file.
Parcel generates source maps by default when you run the build command: parcel build <entry file>
.
After building your application, bundlers generate a directory (typically named dist
) with minified JavaScript files co-located with their corresponding source maps.
See the following example:
./dist
javascript.364758.min.js
javascript.364758.js.map
./subdirectory
javascript.464388.min.js
javascript.464388.js.map
If the sum of the file size for javascript.364758.min.js
and javascript.364758.js.map
exceeds the the 300 MB limit, reduce it by configuring your bundler to split the source code into multiple smaller chunks. For more information, see Code Splitting with WebpackJS.
If the sum of the file size for javascript.364758.min.js
and javascript.364758.js.map
exceeds the the 50 MB limit, reduce it by configuring your bundler to split the source code into multiple smaller chunks. For more information, see Code Splitting with WebpackJS.
The best way to upload source maps is to add an extra step in your CI pipeline and run the dedicated command from the Datadog CLI. It scans the dist
directory and subdirectories to automatically upload source maps with relevant minified files.
Add @datadog/datadog-ci
to your package.json
file (make sure you’re using the latest version).
Create a dedicated Datadog API key and export it as an environment variable named DATADOG_API_KEY
.
Run the following command once per service in your application:
datadog-ci sourcemaps upload /path/to/dist \
--service=my-service \
--release-version=v35.2395005 \
--minified-path-prefix=https://hostname.com/static/js
@datadog/datadog-ci
to your package.json
file (make sure you’re using the latest version).DATADOG_API_KEY
.export DATADOG_SITE=
and export DATADOG_API_HOST=api.
.datadog-ci sourcemaps upload /path/to/dist \
--service=my-service \
--release-version=v35.2395005 \
--minified-path-prefix=https://hostname.com/static/js
To minimize overhead on your CI’s performance, the CLI is optimized to upload as many source maps as you need in a short amount of time (typically a few seconds).
Note: Re-uploading a source map does not override the existing one if the version has not changed.
The --service
and --release-version
parameters must match the service
and version
tags on your Error Tracking events, RUM events, and browser logs. For more information on how to setup these tags, refer to the Browser SDK initialization documentation or Browser Logs Collection documentation.
By running the command against the example dist
directory, Datadog expects your server or CDN to deliver the JavaScript files at https://hostname.com/static/js/javascript.364758.min.js
and https://hostname.com/static/js/subdirectory/javascript.464388.min.js
.
Only source maps with the .js.map
extension work to correctly unminify stack traces. Source maps with other extensions such as .mjs.map
are accepted but do not unminify stack traces.
/static/js
instead of https://hostname.com/static/js
.If you run datadog-ci sourcemaps upload
within a Git working directory, Datadog collects repository metadata. The datadog-ci
command collects the repository URL, the current commit hash, and the list of file paths in the repository that relate to your source maps. For more details about Git metadata collection, refer to the datadog-ci documentation.
Datadog displays links to your source code on unminified stack frames.
Without access to the file path and the line number, a minified stack trace is not helpful in troubleshooting your code base. Also, the code snippet is minified (which means there is one long line of transformed code), making the troubleshooting process more difficult.
The following example displays a minified stack trace:
On the other hand, an unminified stack trace provides you with all the context you need for quick, seamless troubleshooting. For stack frames that relate to your source code, Datadog also generates a direct link to your repository: