Repository navigation
feat(docs): Apply new quick start template to Rust quick start guides #19989
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| --- | ||
| title: Actix Web | ||
| description: "Learn about monitoring your Actix Web application with Sentry." | ||
| description: "Learn how to set up Sentry in your Actix Web application and capture your first events." | ||
| --- | ||
|
|
||
| The Sentry SDK offers a middleware for the [Actix Web](https://actix.rs/) framework that supports: | ||
| The Sentry SDK offers middleware for the [Actix Web](https://actix.rs/) framework that supports: | ||
|
|
||
| - Capturing server errors returned by Actix Web services. | ||
| - Starting a [transaction](/concepts/key-terms/tracing/) for each request-response cycle. | ||
|
|
||
| ## Install | ||
|
|
||
| To add Sentry with the Actix Web integration to your Rust project, add a new dependency to your `Cargo.toml`: | ||
| Add Sentry with the `actix` integration to your `Cargo.toml`: | ||
|
|
||
| ```toml {filename:Cargo.toml} | ||
| [dependencies] | ||
|
|
@@ -20,13 +20,11 @@ sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = | |
|
|
||
| ## Configure | ||
|
|
||
| Initialize and configure the Sentry client. This will enable a set of default integrations, such as panic reporting. | ||
| Then, initialize Actix Web with the Sentry middleware. | ||
| The Sentry middleware provides correct request and trace association for any captured errors or panics, so it should be the first to process the request, that means it should be the last in your chain of `wrap` calls. | ||
| Initialize the Sentry client, then add the Sentry middleware to your Actix Web app. The example route returns an error so you can verify the setup in the next step. | ||
|
|
||
| <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. | ||
| Macros like `#[tokio::main]` and `#[actix_web::main]` are not supported. Initialize the Sentry client before starting the async runtime, as shown below. | ||
|
|
||
| </Alert> | ||
|
|
||
|
|
@@ -45,22 +43,27 @@ fn main() -> io::Result<()> { | |
| sentry::ClientOptions::new() | ||
| .dsn("___PUBLIC_DSN___") | ||
| .maybe_release(sentry::release_name!()) | ||
| // Capture all traces and spans. Set to a lower value in production | ||
| // Enable tracing and capture all traces and spans. | ||
| // Reduce this sample rate in production, or remove it to disable tracing. | ||
| .traces_sample_rate(1.0) | ||
| // Capture user IPs and potentially sensitive headers when using HTTP server integrations | ||
| // see https://docs.sentry.io/platforms/rust/data-management/data-collected for more info | ||
| // Capture user IPs and potentially sensitive headers when using HTTP server integrations. | ||
| // Review the data your app sends before enabling this option in production. | ||
| .send_default_pii(true) | ||
| // Capture all HTTP request bodies, regardless of size | ||
| // Capture all HTTP request bodies, regardless of size. | ||
| .max_request_body_size(sentry::MaxRequestBodySize::Always), | ||
| ); | ||
|
|
||
| actix_web::rt::System::new().block_on(async { | ||
| HttpServer::new(|| { | ||
| App::new() | ||
| // Keep Sentry last in the wrap chain so it processes requests first | ||
| // and associates captured errors and panics with the correct request. | ||
| .wrap( | ||
| sentry::integrations::actix::Sentry::builder() | ||
| .capture_server_errors(true) // Capture server errors | ||
| .start_transaction(true) // Start a transaction (Sentry root span) for each request | ||
| // Report server errors returned by services to Sentry. | ||
| .capture_server_errors(true) | ||
| // Start a transaction (Sentry root span) for each request. | ||
| .start_transaction(true) | ||
| .finish(), | ||
| ) | ||
| .service(failing) | ||
|
|
@@ -74,24 +77,19 @@ fn main() -> io::Result<()> { | |
| } | ||
| ``` | ||
|
|
||
| ## Verify | ||
| ## Verify Your Setup | ||
|
|
||
| The snippet above sets up a service that always fails, so you can test that everything is working as soon as you set it up. | ||
|
|
||
| Send a request to the application. The response error will be captured by Sentry. | ||
| Run the example above, then send a request to its failing route. The route returns an error, and Sentry captures it. | ||
|
|
||
| ```bash | ||
| curl http://localhost:3001/ | ||
| ``` | ||
|
|
||
| <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. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved. | ||
| To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Select **Issues** in the sidebar to find the new issue. | ||
|
Comment on lines
+80
to
+88
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's also a bit confusing that this comes so far after the example, as the verification step only works with specifically that example; it would not work with a generic actix application. |
||
|
|
||
| ## Next Steps | ||
|
|
||
| - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup | ||
| - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup. | ||
| - Learn how to <PlatformLink to="/usage/">manually capture errors</PlatformLink>. | ||
| - Instrument more operations with <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">custom tracing</PlatformLink>. | ||
| - Add <PlatformLink to="/logs/">logs</PlatformLink> and <PlatformLink to="/metrics/">application metrics</PlatformLink> with manual instrumentation. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comments from the actix guide also apply here |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comments from the other guides also apply here. Also, this PR should be rebased on the latest version of the docs, as this guide has been significantly reworked following a redesign of the tracing integration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Companion to previous comment