Skip to content

Commit fc2bff0

Browse files
authored
docs: Update Rust docs and snippets for new release (#1765)
1 parent feef236 commit fc2bff0

File tree

17 files changed

+40
-198
lines changed

17 files changed

+40
-198
lines changed

__tests__/__snapshots__/documentation.js.snap

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,7 @@ Array [
380380
"platforms/react-native/ram-bundles/index.html",
381381
"platforms/react-native/sourcemaps/index.html",
382382
"platforms/rust/actix/index.html",
383-
"platforms/rust/env_logger/index.html",
384-
"platforms/rust/error_chain/index.html",
385-
"platforms/rust/failure/index.html",
386383
"platforms/rust/index.html",
387-
"platforms/rust/log/index.html",
388-
"platforms/rust/panic/index.html",
389384
"project-resources/index.html",
390385
"sdks/javascript/index.html",
391386
"sitemap.xml",

src/_data/platforms.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@
602602
name: Rust
603603
wizard_parent: rust
604604
wizard: true
605-
version: 0.6.0
605+
version: 0.19.0
606606
version_key: SENTRY_VERSION
607607
case_style: snake_case
608608
-

src/collections/_documentation/enriching-error-data/with-scope/rust.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
```rust
2-
use sentry::{Level, with_scope};
3-
use sentry::integrations::failure::capture_error;
4-
use failure::err_msg;
5-
6-
with_scope(|scope| {
2+
sentry::with_scope(|scope| {
73
scope.set_tag("my-tag", "my value");
8-
scope.set_level(Some(Level::Warning));
94
}, || {
105
// will be tagged with my-tag="my value"
11-
capture_error(err_msg("my error"))
6+
sentry::capture_message("my error", sentry::Level::Error)
127
});
138

149
// will not be tagged with my-tag
15-
capture_error(err_msg("my other error"))
10+
sentry::capture_message("my other error", sentry::Level::Error)
1611
```
1712

1813
*Note that in Rust two callbacks are invoked. One for configuring the scope, and a second

src/collections/_documentation/error-reporting/capture-error/rust.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
In Rust you can capture errors that implement the `Fail` trait or that are `failure::Error`
2-
objects:
1+
In Rust, you can capture any `std::error::Error` type.
32

43
```rust
5-
use sentry::integrations::failure::capture_error;
4+
let result = match function_returns_error() {
5+
Ok(result) => result,
6+
Err(err) => {
7+
sentry::capture_error(&err);
8+
return Err(err);
9+
}
10+
};
11+
```
12+
13+
Integrations may provide more specialized capturing methods.
14+
15+
```rust
16+
use sentry::integrations::anyhow::capture_anyhow;
617

7-
let result = match function_that_might_fail() {
18+
let result = match function_returns_anyhow() {
819
Ok(result) => result,
920
Err(err) => {
10-
capture_error(&err);
21+
capture_anyhow(&err);
1122
return Err(err);
1223
}
1324
};
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
```rust
2-
use sentry::{capture_message, Level};
3-
4-
capture_message("Something went wrong", Level::Info);
2+
sentry::capture_message("Something went wrong", sentry::Level::Info);
53
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
```rust
22
sentry::init(sentry::ClientOptions {
3-
before_send: Some(Arc::new(Box::new(|mut event| {
3+
before_send: Some(Arc::new(|mut event| {
44
// Modify event here
55
event.server_name = None; // Don't send server name
66
Some(event)
7-
}))),
7+
})),
88
..Default::default()
99
});
1010
```

src/collections/_documentation/error-reporting/configuration/config-intro/rust.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Options are passed to the `init()` as tuple where the first argument is the DSN and the second the options:
22

33
```rust
4-
use sentry;
5-
64
sentry::init(("___PUBLIC_DSN___", sentry::ClientOptions {
75
max_breadcrumbs: 50,
86
debug: true,

src/collections/_documentation/error-reporting/configuration/drain-example/rust.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ the guard and make sure it disposes on shutdown. Alternatively the client can b
44

55
```rust
66
use std::time::Duration;
7-
use sentry::Hub;
87

9-
if let Some(client) = Hub.current().client() {
8+
if let Some(client) = sentry::Hub::current().client() {
109
client.close(Some(Duration::from_secs(2)));
1110
}
1211
```

src/collections/_documentation/error-reporting/configuration/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ happen as part of the `init()` call, in some others, different patterns apply.
176176
{:.config-key}
177177
### `integrations`
178178

179-
{% unsupported csharp aspnetcore rust %}
179+
{% unsupported csharp aspnetcore %}
180180
In some SDKs, the integrations are configured through this parameter on library initialization.
181181
For more information, have a look at the specific integration documentation.
182182
{% endunsupported %}
183183

184184
{:.config-key}
185185
### `default-integrations`
186186

187-
{% unsupported csharp aspnetcore rust %}
187+
{% unsupported csharp aspnetcore %}
188188
This can be used to disable integrations that are added by default. When set to `false` no
189189
default integrations are added.
190190
{% endunsupported %}

src/collections/_documentation/error-reporting/getting-started-verify/rust.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ The quickest way to verify Sentry in your Rust application is to cause a panic:
44

55
```rust
66
fn main() {
7-
// Initialize sentry here
8-
9-
sentry::integrations::panic::register_panic_handler();
7+
let _guard = sentry::init("___PUBLIC_DSN___");
108

119
// Sentry will capture this
1210
panic!("Everything is on fire!");

src/collections/_documentation/platforms/rust/actix.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In your `Cargo.toml`:
2222
```toml
2323
[dependencies]
2424
sentry = "{% sdk_version sentry.rust %}"
25-
sentry-actix = "{% package_version cargo:sentry-actix %}"
25+
sentry-actix = "{% sdk_version sentry.rust %}"
2626
```
2727

2828
And your Rust code:
@@ -45,7 +45,6 @@ fn failing(_req: &HttpRequest) -> Result<String, Error> {
4545
fn main() {
4646
let _guard = sentry::init("___PUBLIC_DSN___");
4747
env::set_var("RUST_BACKTRACE", "1");
48-
sentry::integrations::panic::register_panic_handler();
4948

5049
server::new(|| {
5150
App::new()

src/collections/_documentation/platforms/rust/env_logger.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/collections/_documentation/platforms/rust/error_chain.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/collections/_documentation/platforms/rust/failure.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/collections/_documentation/platforms/rust/index.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,26 @@ protocol for Rust and provides convenient helpers for sending common types of
99
events to Sentry.
1010

1111
The Rust SDK follows the new unified SDK architecture. To get started have a
12-
look at the [quickstart](/error-reporting/quickstart/?platform=rust) docs.
12+
look at the [quickstart](/error-reporting/quickstart/?platform=rust) docs and the crates [API Docs](https://docs.rs/sentry).
13+
14+
## Quick Start
15+
16+
```rust
17+
let _guard = sentry::init("___PUBLIC_DSN___");
18+
sentry::capture_message("Hello World!", sentry::Level::Info);
19+
```
1320

1421
## Integrations
1522

1623
*Integrations* extend the functionality of the SDK for some common frameworks
1724
and libraries.
1825

19-
### Framework integrations
20-
21-
Sentry-Rust supports the following application frameworks:
22-
23-
* [actix-web](/platforms/rust/actix/)
24-
25-
### Error handling integrations
26-
27-
Sentry-Rust supports the most commonly used libraries for advanced error management:
28-
29-
* [failure](/platforms/rust/failure/)
30-
* [error-chain](/platforms/rust/error_chain/)
31-
32-
Additionally you can catch panics using the panic integration:
33-
34-
* [panic](/platforms/rust/panic/)
35-
36-
### Logging integrations
26+
A list of integrations and their feature flags can be found
27+
[in the integration API docs](https://docs.rs/sentry/0/sentry/integrations/index.html).
3728

38-
Logs can be automatically converted into breadcrumbs.
29+
Apart from those, the Rust SDK also supports the following application frameworks:
3930

40-
* [env_logger](/platforms/rust/env_logger/)
41-
* [log](/platforms/rust/log/)
31+
* [actix-web 0.7](/platforms/rust/actix/)
4232

4333
## More Information
4434

src/collections/_documentation/platforms/rust/log.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/collections/_documentation/platforms/rust/panic.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)