Shutdown and Draining

Learn more about the default behavior of our SDK if the application shuts down unexpectedly.

The default behavior of most SDKs is to send out events over the network asynchronously in the background. This means that some events might be lost if the application shuts down unexpectedly. The SDKs provide mechanisms to cope with this.

To avoid unintentionally dropping events when the program terminates, arrange for sentry.Flush to be called, typically using defer.

If you use multiple clients, arrange for each of them to be flushed as appropriate.

Flush waits until any buffered events are sent to the Sentry server, blocking for at most the given timeout. It returns false if the timeout was reached. In that case, some events may not have been sent.

func main() {
	// err := sentry.Init(...)
	defer sentry.Flush(2 * time.Second)

	sentry.CaptureMessage("my message")
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").