Skip to content

Commit 51e7a2a

Browse files
ribicebitsandfoxes
authored andcommitted
add example for FlushWithContext() (#12308)
1 parent feafb75 commit 51e7a2a

File tree

1 file changed

+14
-0
lines changed
  • platform-includes/configuration/drain-example

1 file changed

+14
-0
lines changed

platform-includes/configuration/drain-example/go.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,17 @@ func main() {
1616
sentry.CaptureMessage("my message")
1717
}
1818
```
19+
20+
`FlushWithContext` is an alternative to Flush that uses a context.Context to manage the timeout or cancellation of the flush operation. This approach is particularly useful in applications where you are already using contexts for managing deadlines and cancellations.
21+
22+
23+
```go
24+
func main() {
25+
// err := sentry.Init(...)
26+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
27+
defer cancel()
28+
29+
sentry.CaptureMessage("my message")
30+
sentry.FlushWithContext(ctx)
31+
}
32+
```

0 commit comments

Comments
 (0)