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.
- hog, the PostHog CLI. We recommend keeping it up to date with
hog upgrade.
- 1
Install hog
Required - 2
Authenticate
RequiredLog in to PostHog. This opens your browser, where you approve the login:
TerminalIf posthog-cli is already logged in on this machine, import that login instead:
TerminalThese CI providers can upload with the job's OIDC token, so you don't store a personal API key in CI.
- Logged in with
hog auth login, run this once in the repository:
Terminal- An organization admin approves the request in PostHog.
- Add the
hostandprojectIdthat hog prints toposthog.json, and add the snippet it prints to the job.
In GitHub Actions, the job needs the
id-token: writepermission:YAMLRemove any personal API key from the job. A key wins over the OIDC token.
Set these environment variables in the job:
Environment variable Description Source HOG_HOSTThe PostHog host to connect to, such as https://eu.posthog.com[default: https://us.posthog.com]Project settings HOG_PROJECT_IDPostHog project ID Project settings HOG_PERSONAL_API_KEYPersonal API key with the error_tracking:writescopeAPI key settings hog reads only the
HOG_*names. The PostHog build plugins and upload scripts still pass the oldPOSTHOG_CLI_*names to hog for now, with a warning for each one. Ahogcommand you run yourself needs theHOG_*names. The migration guide lists each rename. - 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 and standalone Mach-O binaries that embed their own DWARF, splitting universal (fat) binaries into one symbol set per architecture slice. 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, log in as the Authenticate step describes. For GitHub Actions, with the job's OIDC token:
YAMLIn other CI providers, set
HOG_PERSONAL_API_KEYandHOG_PROJECT_IDon the upload step only. The build itself doesn't need them.hog defaults to US Cloud. If you're on EU Cloud or self-hosted, also set
HOG_HOST(for examplehttps://eu.posthog.com), orhostinposthog.json.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.





