Skip to content

Commit de9699d

Browse files
committed
improve
1 parent ab9268f commit de9699d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

docs/platforms/rust/guides/tracing/index.mdx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ sentry = { version = "{{@inject packages.version('sentry.rust') }}", features =
2727
"logs",
2828
# ___PRODUCT_OPTION_END___ logs
2929
] }
30+
tokio = { version = "1.45.0", features = ["full"] }
3031
```
3132

3233
## Configure
3334

3435
Initialize the Sentry SDK and register the Sentry layer to start sending `tracing` events and spans to Sentry:
3536

37+
<Alert level="warning">
38+
39+
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.
40+
41+
</Alert>
42+
3643
```rust
3744
use tracing_subscriber::prelude::*;
3845

@@ -56,12 +63,17 @@ fn main() {
5663
// Register the Sentry tracing layer
5764
tracing_subscriber::registry()
5865
.with(tracing_subscriber::fmt::layer())
59-
.with(sentry_layer)
66+
.with(sentry::integrations::tracing::layer())
6067
.init();
61-
62-
// Futures should to be bound to a Hub
63-
// Learn more at https://docs.rs/sentry-core/latest/sentry_core/#parallelism-concurrency-and-async
64-
fail().bind_hub(sentry::Hub::current()).await;
68+
69+
tokio::runtime::Builder::new_multi_thread()
70+
.enable_all()
71+
.build()?
72+
.block_on(async {
73+
// Futures should to be bound to a Hub
74+
// Learn more at https://docs.rs/sentry-core/latest/sentry_core/#parallelism-concurrency-and-async
75+
fail().bind_hub(sentry::Hub::current()).await;
76+
});
6577
}
6678

6779
# ___PRODUCT_OPTION_START___ performance

0 commit comments

Comments
 (0)