Upload debug symbols for Rust
The Rust SDK resolves stack traces in-process from whatever debug info the running binary carries — which works well in development, but release builds omit that debug info by default. Uploading debug symbols gives you fully resolved production stack traces: PostHog symbolicates frames server-side from the exact build that crashed, resolves inlined frames, and can display the source code around each frame.
- posthog-rs 0.16.0 or later, which records the instruction addresses server-side symbolication needs. We recommend the latest version.
- CLI 0.7.32 or later for Linux binaries. Uploading macOS
.dSYMbundles with the same command needs CLI 0.8.1 or later. As always, we recommend keeping up with the latest CLI version.
- 1
Download CLI
RequiredInstall
posthog-cli: - 2
Authenticate
RequiredTo authenticate the CLI, call the
logincommand. This opens your browser where you select your organization, project, and API scopes to grant:TerminalIf you are using the CLI in a CI/CD environment such as GitHub Actions, you can set environment variables to authenticate:
Environment Variable Description Source POSTHOG_CLI_HOSTThe PostHog host to connect to [default: https://us.posthog.com] Project settings POSTHOG_CLI_PROJECT_IDPostHog project ID Project settings POSTHOG_CLI_API_KEYPersonal API key with error tracking writeandorganization readscopesAPI key settings You can also use the
--hostoption instead of thePOSTHOG_CLI_HOSTenvironment variable to target a different PostHog instance or region. For EU users:Terminal - 3
Keep debug info in release builds
RequiredCargo omits debug info from release builds by default, and there is nothing to upload without it. Enable it in your
Cargo.toml:tomlline-tables-onlyis enough to resolve file names, line numbers, and inlined frames while keeping binaries small. Usedebug = "full"if you want complete debug info.On macOS, also set
split-debuginfo = "packed"in the same profile. Cargo's macOS default (unpacked) leaves debug info in intermediate object files instead of producing the.dSYMbundle the CLI uploads.Watch out for stripping: if your profile sets
stripexplicitly, set it to"none"— or strip only after the upload runs. Debug info split into separate files also works: the CLI picks upobjcopy --only-keep-debugcompanion files alongside the binaries. - 4
Check for a build ID
RequiredPostHog matches stack frames to uploaded symbols by the binary's unique build ID: a GNU build ID on Linux, or the Mach-O UUID on macOS. macOS binaries always carry a UUID, so there is nothing to check there. Most Linux toolchains emit a GNU build ID by default — confirm yours does:
TerminalReplace
my-appwith your binary's name.If nothing shows up, tell the linker to add one in
.cargo/config.toml, scoped to Linux builds (Apple's linker embeds a UUID on its own and rejects this flag):toml - 5
Build and upload
RequiredAfter your release build, point the CLI at the build output directory:
TerminalThe CLI scans the directory and uploads every executable and shared library that carries debug info and a build ID, skipping everything else. On macOS it also uploads
.dSYMbundles (this needsdwarfdump, which ships with Xcode). Windows binaries (PDB debug info) are not supported yet. The upload is associated with a release automatically when the build directory is inside a git checkout.Run this as part of the same pipeline that produces your production binary. Each build has its own build ID, so symbols must be re-uploaded for every build you deploy.
- 6
Optional: Include source code context
OptionalBy default, only debug symbols are uploaded. To also display the source code around each frame in your stack traces, add
--include-source:TerminalThis bundles the project source files referenced by the debug info into the upload. It increases upload size, so only enable it if you want source context in the error tracking UI.
- 7
Optional: Upload from CI
OptionalIn CI, authenticate with environment variables instead of
posthog-cli login. For GitHub Actions:YAMLScope the credentials to the upload step only — the build itself doesn't need them.
The CLI defaults to US Cloud. If you are on EU Cloud or self-hosted, also set
POSTHOG_CLI_HOST(for examplehttps://eu.posthog.com).If your binary is built inside a Dockerfile, run the upload in the build stage right after the build, and pass the credentials in as build secrets so they never reach the runtime image.
- 9
Test it end-to-end
OptionalCapture a test exception from the same release binary the symbols were uploaded for:
RustRun the binary, then check the error tracking issues view: the stack trace should resolve to your source files, including source context if you uploaded with
--include-source. A rebuild changes the build ID, so if you rebuild, upload again before testing.