From a000ee8747a912b4d49625bf7c4917773da0fb7f Mon Sep 17 00:00:00 2001 From: lcian Date: Fri, 28 Mar 2025 14:01:50 +0100 Subject: [PATCH 1/4] feat(rust): document how to set up source context --- .../rust/common/source-context/index.mdx | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/platforms/rust/common/source-context/index.mdx diff --git a/docs/platforms/rust/common/source-context/index.mdx b/docs/platforms/rust/common/source-context/index.mdx new file mode 100644 index 0000000000000..2af67d9af076a --- /dev/null +++ b/docs/platforms/rust/common/source-context/index.mdx @@ -0,0 +1,40 @@ +--- +title: Source Context +sidebar_order: 2400 +description: "Learn about showing your source code as part of stack traces." +--- + +## Prerequisites + +[Install](cli/installation/) and [Configure](cli/configuration/) Sentry CLI by providing an auth token, org and project. + +Then, enable full debug information for your release build: +```toml {filename:Cargo.toml} +[profiles.release] +debug = true +``` + +We will strip the binary, extract the necessary debug information and upload it to Sentry along with the source code. + +## Upload debug information files and source code + +Build the release binary, strip and extract debug information: +```bash +cargo build --release +objcopy --only-keep-debug target/release/app{,.d} +objcopy --strip-debug --strip-unneeded target/release/app +objcopy --add-gnu-debuglink target/release/app{.d,} +zip app-debug.zip target/release/app.d +``` + +Use Sentry CLI to create a source bundle: + +```bash +sentry-cli difutil bundle-sources target/release/app.d +mv target/release/app.src.zip ./app.src.zip +``` + +Finally, use Sentry CLI to upload both debug information files and sources to Sentry: +```bash +sentry-cli upload-dif ./app-debug.zip ./app.src.zip +``` From 40424d3bae089a9ab1d238d8323a27486d3bc884 Mon Sep 17 00:00:00 2001 From: lcian Date: Fri, 28 Mar 2025 15:15:16 +0100 Subject: [PATCH 2/4] 404s --- docs/platforms/rust/common/source-context/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/rust/common/source-context/index.mdx b/docs/platforms/rust/common/source-context/index.mdx index 2af67d9af076a..01c8173940cdf 100644 --- a/docs/platforms/rust/common/source-context/index.mdx +++ b/docs/platforms/rust/common/source-context/index.mdx @@ -6,7 +6,7 @@ description: "Learn about showing your source code as part of stack traces." ## Prerequisites -[Install](cli/installation/) and [Configure](cli/configuration/) Sentry CLI by providing an auth token, org and project. +[Install](/cli/installation/) and [Configure](/cli/configuration/) Sentry CLI by providing an auth token, org and project. Then, enable full debug information for your release build: ```toml {filename:Cargo.toml} From d0fa717202d9bfba701fbf40967726dade8871a9 Mon Sep 17 00:00:00 2001 From: Lorenzo Cian Date: Wed, 2 Apr 2025 15:06:23 +0200 Subject: [PATCH 3/4] Update index.mdx --- .../rust/common/source-context/index.mdx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/platforms/rust/common/source-context/index.mdx b/docs/platforms/rust/common/source-context/index.mdx index 01c8173940cdf..e293bd587d46c 100644 --- a/docs/platforms/rust/common/source-context/index.mdx +++ b/docs/platforms/rust/common/source-context/index.mdx @@ -14,27 +14,22 @@ Then, enable full debug information for your release build: debug = true ``` -We will strip the binary, extract the necessary debug information and upload it to Sentry along with the source code. +The binary will be stripped of the debug information which will be collected along with the source code and uploaded to Sentry. ## Upload debug information files and source code -Build the release binary, strip and extract debug information: +Build the release binary, extract debug information and strip it from the binary: ```bash cargo build --release objcopy --only-keep-debug target/release/app{,.d} objcopy --strip-debug --strip-unneeded target/release/app objcopy --add-gnu-debuglink target/release/app{.d,} -zip app-debug.zip target/release/app.d ``` -Use Sentry CLI to create a source bundle: +If you don't want to strip the binary, you should disable the `debug-images` integration of the SDK, as otherwise you will run into the issue documented [here](https://github.com/getsentry/sentry-rust/issues/470#issuecomment-1472136215) which could cause duplicated frames to appear in your Sentry issues. -```bash -sentry-cli difutil bundle-sources target/release/app.d -mv target/release/app.src.zip ./app.src.zip -``` +Use Sentry CLI to upload debug information and source files: -Finally, use Sentry CLI to upload both debug information files and sources to Sentry: -```bash -sentry-cli upload-dif ./app-debug.zip ./app.src.zip +```bash +sentry-cli debug-files upload --include-sources . ``` From 8b188cec88f62ffe08346ee9cf5939a9766b1612 Mon Sep 17 00:00:00 2001 From: Lorenzo Cian Date: Wed, 2 Apr 2025 15:07:23 +0200 Subject: [PATCH 4/4] Update index.mdx --- docs/platforms/rust/common/source-context/index.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/platforms/rust/common/source-context/index.mdx b/docs/platforms/rust/common/source-context/index.mdx index e293bd587d46c..6e7a174975e09 100644 --- a/docs/platforms/rust/common/source-context/index.mdx +++ b/docs/platforms/rust/common/source-context/index.mdx @@ -14,8 +14,6 @@ Then, enable full debug information for your release build: debug = true ``` -The binary will be stripped of the debug information which will be collected along with the source code and uploaded to Sentry. - ## Upload debug information files and source code Build the release binary, extract debug information and strip it from the binary: