Am I correct that in the Go project to send messages immediately, the Flush method must be used?
When I try sending messages without Flush()
it just doesn't work.
From the docs:
Flush waits until the underlying Transport sends any buffered events 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.
Flush should be called before terminating the program to avoid unintentionally dropping events.
Do not call Flush indiscriminately after every call to CaptureEvent, CaptureException or CaptureMessage. Instead, to have the SDK send events over the network synchronously, configure it to use the HTTPSyncTransport in the call to Init.
So while the problem you are asking about is a "valid" one in case you need to be sure a message is indeed sent to the server, the solution you are proposing (calling Flush()
after a CaptureMessage()
), is actively discouraged by the SDK authors. Instead, consider something like:
sentry.Init(sentry.ClientOptions{
Transport: sentry.NewHTTPSyncTransport(),
// ...
})