-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(rust): add troubleshooting page #14595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c11aa8c
feat(rust): add getting started docs for tracing
lcian ab9268f
feat(rust): add getting started docs for tracing
lcian de9699d
improve
lcian b5dec54
Merge branch 'master' into lcian/feat/rust-tracing-docs
lcian d1bace4
feat(rust): add troubleshooting page
lcian 6f5c53c
Apply suggestion from @coolguyzone
lcian 7755205
Update index.mdx
lcian 6a18667
Apply suggestion from @coolguyzone
lcian c377e72
Apply suggestion from @alexander-alderman-webb
lcian 0137ae7
Merge branch 'master' into lcian/feat/rust-troubleshooting-page
lcian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| title: Troubleshooting | ||
| sidebar_order: 9000 | ||
| description: "If you need help solving issues with the Sentry Rust SDK, you can read the edge cases documented below." | ||
| --- | ||
|
|
||
| To start debugging any SDK issue, enable debug mode by setting `debug: true` in the `ClientOptions` struct you pass to `sentry::init`. | ||
| This will make the SDK log additional debug information on stderr. | ||
|
|
||
| Below is a list of common problems and how to solve them. | ||
|
|
||
| ## General | ||
|
|
||
| <Expandable title="Panic on SDK initialization"> | ||
| Users have reported SDK initialization to panic when using the `debug-images` feature on machines with specific Linux platforms. | ||
|
|
||
| Please open a GitHub [issue](https://github.com/getsentry/sentry-rust/issues/new/choose) with your OS and kernel version if you're affected by this. | ||
| </Expandable> | ||
|
|
||
| <Expandable title="Duplicated stack frames"> | ||
| There's an issue where stack frames can appear to be duplicated in Sentry with respect to the real stack trace. | ||
| As there's a currently a hard limit of 200 frames in ingestion, this can cause errors to be missing stack frames when the limit is exceeded. | ||
| This happens when the stack trace is already symbolicated on the client (due to debug information being present at runtime) but gets resymbolicated on the server. | ||
|
|
||
| There are two alternative ways to address this problem: | ||
| - keep debug information in the binary, but disable the `debug-images` feature of the `sentry` crate; | ||
| - strip debug information from the binary, and [upload debug files](/platforms/rust/source-context/#compile-and-create-debug-information-files) separately. | ||
| </Expandable> | ||
|
|
||
|
|
||
| <Expandable title="'This frame has an unknown problem and can not be symbolicated' error in the UI for application stack frames"> | ||
| This can happen when your executable doesn't have a build ID, and therefore stack frames cannot be associated with any debug files by the Sentry backend. | ||
|
|
||
| To ensure `cargo` embeds a build ID in your binary, set the following environment variable when building: `RUSTFLAGS="-Clink-args=-Wl,--build-id"`. | ||
| </Expandable> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| title: tracing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| --- | ||
| title: tracing | ||
| description: "Learn about monitoring your Rust application with Sentry's tracing integration." | ||
| --- | ||
|
|
||
| The Sentry SDK offers an integration for tokio's [tracing](https://github.com/tokio-rs/tracing) ecosystem that supports: | ||
|
|
||
| - Reporting `tracing` events to Sentry as events, breadcrumbs, or logs. | ||
| - Reporting `tracing` spans to Sentry. | ||
| - Reporting errors and panics with the correct trace correlation. | ||
|
|
||
| ## Install | ||
|
|
||
| <OnboardingOptionButtons | ||
| options={["error-monitoring", "performance", "logs"]} | ||
| /> | ||
|
|
||
| To add Sentry with the `tracing` integration to your Rust project, add the necessary dependencies to your `Cargo.toml`: | ||
|
|
||
| ```toml {filename:Cargo.toml} | ||
| [dependencies] | ||
| tracing = "0.1.41" | ||
| tracing-subscriber = "0.3.19" | ||
| sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = [ | ||
| "tracing", | ||
| # ___PRODUCT_OPTION_START___ logs | ||
| "logs", | ||
| # ___PRODUCT_OPTION_END___ logs | ||
| ] } | ||
| tokio = { version = "1.45.0", features = ["full"] } | ||
| ``` | ||
|
|
||
| ## Configure | ||
|
|
||
| Initialize the Sentry SDK and register the Sentry layer to start sending `tracing` events and spans to Sentry: | ||
|
|
||
| <Alert level="warning"> | ||
|
|
||
| Macros like `#[tokio::main]` and `#[actix_web::main]` are not supported. The Sentry client must be initialized before the async runtime is started, as shown below. | ||
|
|
||
| </Alert> | ||
|
|
||
| ```rust | ||
| use tracing_subscriber::prelude::*; | ||
|
|
||
| fn main() { | ||
| // Initialize Sentry | ||
| let _guard = sentry::init(( | ||
| "___PUBLIC_DSN___", | ||
| sentry::ClientOptions { | ||
| release: sentry::release_name!(), | ||
| # ___PRODUCT_OPTION_START___ performance | ||
| // Capture all traces and spans. Set to a lower value in production | ||
| traces_sample_rate: 1.0, | ||
| # ___PRODUCT_OPTION_END___ performance | ||
| # ___PRODUCT_OPTION_START___ logs | ||
| enable_logs:true | ||
| # ___PRODUCT_OPTION_END___ logs | ||
| ..sentry::ClientOptions::default() | ||
| }, | ||
| }); | ||
|
|
||
| // Register the Sentry tracing layer | ||
| tracing_subscriber::registry() | ||
| .with(tracing_subscriber::fmt::layer()) | ||
| .with(sentry::integrations::tracing::layer()) | ||
| .init(); | ||
|
|
||
| tokio::runtime::Builder::new_multi_thread() | ||
| .enable_all() | ||
| .build()? | ||
| .block_on(async { | ||
| // Futures should to be bound to a Hub | ||
| // Learn more at https://docs.rs/sentry-core/latest/sentry_core/#parallelism-concurrency-and-async | ||
| fail().bind_hub(sentry::Hub::current()).await; | ||
| }); | ||
| } | ||
|
|
||
| # ___PRODUCT_OPTION_START___ performance | ||
| #[tracing::instrument] // Captures a root span (transaction) around this function execution | ||
| # ___PRODUCT_OPTION_END___ performance | ||
| async fn fail() { | ||
| tracing::debug!("Doing work"); // Adds a breadrcumb | ||
| # ___PRODUCT_OPTION_START___ performance | ||
| let _span = tracing::info_span("Child span").entered(); // Captures a child span | ||
| # ___PRODUCT_OPTION_END___ performance | ||
| tracing::error!("Everything is on fire!"); | ||
| } | ||
| ``` | ||
|
|
||
| By default, error level events are captured as Sentry events, while anything at or above info is added as a breadcrumb. | ||
|
|
||
| {/* ___PRODUCT_OPTION_START___ logs */} | ||
|
|
||
| To capture structured logs for `tracing` events instead, you need to set up the Sentry layer with a custom event filter that maps to logs, like so: | ||
|
|
||
| ```rust | ||
| use sentry::integrations::tracing::EventFilter; | ||
|
|
||
| sentry::integrations::tracing::layer().event_filter(|md| match *md.level() { | ||
| // Capture error level events as Sentry events | ||
| tracing::Level::ERROR => EventFilter::Event, | ||
| // Ignore trace level events, as they're too verbose | ||
| tracing::Level::TRACE => EventFilter::Ignore, | ||
| // Capture everything else as a structured log | ||
| _ => EventFilter::Log, | ||
| }); | ||
| ``` | ||
|
|
||
| {/* ___PRODUCT_OPTION_END___ logs */} | ||
|
|
||
| ## Verify | ||
|
|
||
| <Alert> | ||
|
|
||
| Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Select Issues, and then Errors & Outages in the sidebar, where you will find the newly created issue. Clicking on the issue's title will open a page where you can see detailed information and mark it as resolved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.