Open kucherenkovova opened 1 year ago
Could you explain your use case in a bit more detail? By default, the SDK is supposed to run all the time so it can capture errors and send performance data.
Hi @cleptric! We don't explicitly instantiate HTTPTransport
in our app.
Our initialization code looks like this:
hub := sentry.NewHub(nil, sentry.NewScope())
client, _ := sentry.NewClient(opts)
hub.BindClient(client)
...
hub.CaptureException(err)
I noticed that during the shutdown process, our service has a leaked goroutine. It is not critical for my case at all. I agree that most of the use cases for sentry fall into category "live as long as the process does". However, I can think of resource-limited environments where one might want to tear down all the sentry-allocated resources when it's no longer needed. It'd be really nice to have some API for this behavior.
I would recommend using the HTTPSyncTransport
, see https://docs.sentry.io/platforms/go/configuration/transports/#usage.
I've encountered this too when working on Profiling in the past - it's causing issues in tests because we have outstanding HTTP transport workers that stay running indefinitely.
I guess this can be solved in #111 which is still open and on the backlog
Summary
You iterate over a channel in a separate goroutine. This channel is never closed which leads to a goroutine leak.
Steps To Reproduce
Install
"go.uber.org/goleak"
and add the following code totransport_test.go
fileoutput:
Expected Behavior
As a user, I want to be able to tear down all the sentry-allocated resources when it's no longer needed.
SDK
sentry-go
version: v0.25.0