You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/rust/guides/axum/index.mdx
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,13 @@ The integration actually supports any crate based on [tower](https://github.com/
12
12
13
13
## Install
14
14
15
+
<OnboardingOptionButtons
16
+
options={["error-monitoring", "performance"]}
17
+
/>
18
+
15
19
To add Sentry with the `axum` integration to your Rust project, add a new dependency to your `Cargo.toml`:
16
20
17
-
```toml {filename:Cargo.toml}
21
+
```toml {filename:Cargo.toml}
18
22
[dependencies]
19
23
axum = "0.8.4"
20
24
tower = "0.5.2"
@@ -27,6 +31,8 @@ sentry = { version = "{{@inject packages.version('sentry.rust') }}", features =
27
31
Initialize and configure the Sentry client. This will enable a set of default integrations, such as panic reporting.
28
32
Then, initialize `axum` with the Sentry middleware.
29
33
34
+
This snippet sets up a service that always panics, so you can test that everything is working as soon as you set it up.
35
+
30
36
<Alertlevel="warning">
31
37
32
38
Macros like `#[tokio::main]` are not supported. The Sentry client must be initialized before the async runtime is started, as shown below.
@@ -48,8 +54,10 @@ fn main() -> io::Result<()> {
48
54
"___PUBLIC_DSN___",
49
55
sentry::ClientOptions {
50
56
release:sentry::release_name!(),
57
+
# ___PRODUCT_OPTION_START___ performance
51
58
// Capture all traces and spans. Set to a lower value in production
52
59
traces_sample_rate:1.0,
60
+
# ___PRODUCT_OPTION_END___ performance
53
61
// Capture user IPs and potentially sensitive headers when using HTTP server integrations
54
62
// see https://docs.sentry.io/platforms/rust/data-management/data-collected for more info
55
63
send_default_pii:true,
@@ -61,7 +69,9 @@ fn main() -> io::Result<()> {
61
69
ServiceBuilder::new()
62
70
// If you're binding the layers directly on the `Router`, bind them in the opposite order, otherwise you might run into a memory leak
63
71
.layer(NewSentryLayer::<Request<Body>>::new_from_top()) // Bind a new Hub per request, to ensure correct error <> request correlation
72
+
# ___PRODUCT_OPTION_START___ performance
64
73
.layer(SentryHttpLayer::new().enable_transaction()), // Start a transaction (Sentry root span) for each request
74
+
# ___PRODUCT_OPTION_END___ performance
65
75
);
66
76
67
77
tokio::runtime::Builder::new_multi_thread()
@@ -82,8 +92,6 @@ fn main() -> io::Result<()> {
82
92
83
93
## Verify
84
94
85
-
The snippet above sets up a service that always panics, so you can test that everything is working as soon as you set it up.
86
-
87
95
Send a request to the application. The panic will be captured by Sentry.
88
96
89
97
```bash
@@ -96,4 +104,4 @@ Learn more about manually capturing an error or message in our <PlatformLink to=
96
104
97
105
</Alert>
98
106
99
-
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.
107
+
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.
0 commit comments