File tree Expand file tree Collapse file tree 6 files changed +41
-25
lines changed
src/collections/_documentation/error-reporting/configuration Expand file tree Collapse file tree 6 files changed +41
-25
lines changed Original file line number Diff line number Diff line change 1
- The client provides a ` Flush ` method that takes the time in ` time.Duration ` for how long it waits and will return a boolean that indicates whether everything was flushed or the timeout kicked in.
1
+ To avoid unintentionally dropping events when the program terminates, arrange
2
+ for ` sentry.Flush ` to be called, typically using ` defer ` .
3
+
4
+ If you use multiple clients, arrange for each of them to be flushed as
5
+ appropriate.
6
+
7
+ ` Flush ` waits until any buffered events are sent to the Sentry server, blocking
8
+ for at most the given timeout. It returns ` false ` if the timeout was reached. In
9
+ that case, some events may not have been sent.
2
10
3
11
``` go
4
- sentry.CaptureMessage (" my message" )
12
+ func main () {
13
+ // err := sentry.Init(...)
14
+ defer sentry.Flush (2 * time.Second )
5
15
6
- if sentry.Flush (time.Second * 2 ) {
7
- fmt.Println (" All queued events delivered!" )
8
- } else {
9
- fmt.Println (" Flush timeout reached" )
16
+ sentry.CaptureMessage (" my message" )
10
17
}
11
18
```
Original file line number Diff line number Diff line change 1
- The client provides a close method that optionally takes the time in milliseconds for how long it
2
- waits and will return a promise that resolves when everything was flushed or the timeout kicked
1
+ The ` close ` method optionally takes a timeout in milliseconds and returns a
2
+ promise that resolves when all pending events are flushed, or the timeout kicks
3
3
in.
4
4
5
5
``` javascript
6
- const client = Sentry .getCurrentHub ().getClient ();
7
- if (client) {
8
- client .close (2000 ).then (function () {
9
- process .exit ();
10
- });
11
- }
6
+ Sentry .close (2000 ).then (function () {
7
+ process .exit ();
8
+ });
12
9
```
10
+
11
+ After a call to ` close ` , the current client cannot be used anymore. It's
12
+ important to only call ` close ` immediately before shutting down the application.
13
+
14
+ Alternatively, the ` flush ` method drains the event queue while keeping the
15
+ client enabled for continued use.
Original file line number Diff line number Diff line change @@ -6,3 +6,6 @@ sentry_shutdown();
6
6
7
7
Calling ` sentry_shutdown() ` before exiting the application is critical to avoid
8
8
data loss.
9
+
10
+ After shutdown, the client cannot be used anymore. It's important to only call
11
+ ` sentry_shutdown() ` immediately before shutting down the application.
Original file line number Diff line number Diff line change @@ -8,3 +8,9 @@ client = Hub.current.client
8
8
if client is not None :
9
9
client.close(timeout = 2.0 )
10
10
```
11
+
12
+ After a call to ` close ` , the client cannot be used anymore. It's important to
13
+ only call ` close ` immediately before shutting down the application.
14
+
15
+ Alternatively, the ` flush ` method drains the event queue while keeping the
16
+ client enabled for continued use.
Original file line number Diff line number Diff line change @@ -2,11 +2,14 @@ When the Rust SDK initializes a guard is returned from the `init` function. The
2
2
will automatically wait ` shutdown_timeout ` seconds. This means you just need to hold on to
3
3
the guard and make sure it disposes on shutdown. Alternatively the client can be closed:
4
4
5
- ``` javascript
5
+ ``` rust
6
6
use std :: time :: Duration ;
7
7
use sentry :: Hub ;
8
8
9
9
if let Some (client ) = Hub . current (). client () {
10
10
client . close (Some (Duration :: from_secs (2 )));
11
11
}
12
12
```
13
+
14
+ After a call to ` close ` , the client cannot be used anymore. It's important to
15
+ only call ` close ` immediately before shutting down the application.
Original file line number Diff line number Diff line change @@ -3,15 +3,9 @@ title: 'Shutdown and Draining'
3
3
sidebar_order : 1
4
4
---
5
5
6
- Most SDKs use a background queue to send out events. Because the queue sends asynchronously in the background
7
- it means that some events might be lost if the application shuts down unexpectedly. To prevent this all SDKs
8
- provide mechanisms to cope with this.
9
-
10
- Typically SDKs provide two ways to shut down: a controlled shutdown where the system will wait up to about two
11
- seconds to flush out events (configurable) and an uncontrolled shutdown (also referred to as "killing" the
12
- client).
6
+ The default behavior of most SDKs is to send out events over the network
7
+ asynchronously in the background. This means that some events might be lost if
8
+ the application shuts down unexpectedly. The SDKs provide mechanisms to cope
9
+ with this.
13
10
14
11
{% include components/platform_content.html content_dir='drain-example' %}
15
-
16
- After shutdown the client cannot be used any more so make sure to only do that right before you shut down
17
- the application.
You can’t perform that action at this time.
0 commit comments