github getsentry/sentry-go v0.31.0
0.31.0

latest releases: v0.31.1, zerolog/v0.31.1, slog/v0.31.1...
6 days ago

Breaking Changes

  • Remove support for metrics. Read more about the end of the Metrics beta here. (#914)

  • Remove support for profiling. (#915)

  • Remove Segment field from the User struct. This field is no longer used in the Sentry product. (#928)

  • Every integration is now a separate module, reducing the binary size and number of dependencies. Once you update sentry-go to latest version, you'll need to go get the integration you want to use. For example, if you want to use the echo integration, you'll need to run go get github.com/getsentry/sentry-go/echo (#919).

Features

  • Add the ability to override hub in context for integrations that use custom context. (#931)

  • Add HubProvider Hook for sentrylogrus, enabling dynamic Sentry hub allocation for each log entry or goroutine. (#936)

This change enhances compatibility with Sentry's recommendation of using separate hubs per goroutine. To ensure a separate Sentry hub for each goroutine, configure the HubProvider like this:

hook, err := sentrylogrus.New(nil, sentry.ClientOptions{})
if err != nil {
    log.Fatalf("Failed to initialize Sentry hook: %v", err)
}

// Set a custom HubProvider to generate a new hub for each goroutine or log entry
hook.SetHubProvider(func() *sentry.Hub {
    client, _ := sentry.NewClient(sentry.ClientOptions{})
    return sentry.NewHub(client, sentry.NewScope())
})

logrus.AddHook(hook)

Bug Fixes

  • Add support for closing worker goroutines started by the HTTPTranport to prevent goroutine leaks. (#894)
client, _ := sentry.NewClient()
defer client.Close()

Worker can be also closed by calling Close() method on the HTTPTransport instance. Close should be called after Flush and before terminating the program otherwise some events may be lost.

transport := sentry.NewHTTPTransport()
defer transport.Close()

Misc

Don't miss a new sentry-go release

NewReleases is sending notifications on new releases.