Repository navigation
1.0.0-alpha.1
Pre-release
Pre-release
Breaking Changes 🛠
- Replace the event-based transports with envelope-based ones. Custom transports need to implement the new
Transportinterface. See the transport section of the migration guide for details. by @giortzisg in #1427- Custom transports need to implement
SendEnvelope(ctx, envelope)in place ofSendEvent(event), andFlushWithContext(ctx)in place ofFlush(timeout). The envelope types live in the new publicprotocolpackage. - The transport
Timeoutnow applies to every request, including when a customHTTPClientis set. ClientOptions.DisableTelemetryBufferis removed. The telemetry buffer is always used.- Transport
BufferSizenow counts envelopes instead of events, and defaults to 1000 instead of 30.
// Before func (t *customTransport) SendEvent(event *sentry.Event) {} func (t *customTransport) Flush(timeout time.Duration) bool { return true } // After func (t *customTransport) SendEnvelope(ctx context.Context, envelope *protocol.Envelope) error { return nil } func (t *customTransport) FlushWithContext(ctx context.Context) bool { return true }
- Custom transports need to implement
- Remove the
HubAPI. Scopes and clients are now carried oncontext.Context, so users need to pass the request or job context to Sentry functions instead of using a hub. See the migration guide for every replacement. by @giortzisg in #1407CaptureException,CaptureMessage,CaptureEvent,CaptureCheckIn,AddBreadcrumb,RecoverandWithMonitornow take a context as their first argument. Hints and levels are passed as options, such assentry.WithEventHint(hint)andsentry.WithLevel(level).- Use
ctx, scope := sentry.WithScope(ctx)to isolate data for a request or job, instead of cloning a hub or callingPushScope. Usesentry.GlobalScope()for application-wide data, instead ofConfigureScope. - Use
sentry.ScopeFromContext(ctx)andsentry.ClientFromContext(ctx)to read the current scope and client, andsentry.ContextWithScopeandsentry.ContextWithClientto attach your own, instead ofNewHubandSetHubOnContext. - In Gin, Echo, Iris, Fiber and FastHTTP handlers, call the integration's
GetContext(c)and pass the result to Sentry functions.GetHubFromContext,SetHubOnContextandGetSpanFromContextare removed. - Use
sentry.ContinueFromHeaders(trace, baggage)to continue a trace andsentry.SpanFromContext(ctx)to read the active span.ContinueTrace,ContinueFromTrace,Scope.GetSpanandScope.SetSpanare removed. EventModifierand theClient.EventFromMessage,EventFromExceptionandEventFromCheckInhelpers are removed. UseBeforeSendor an event processor to modify events.- Tags and a level set directly on an event are no longer overwritten by the scope.
sentry.AddBreadcrumbandsentry.LastEventIDneed a context that carries a scope. On a bare context such ascontext.Background()the breadcrumb is dropped and the ID is empty. Users should create a scope withsentry.WithScopefirst.- A context that carries neither a scope nor a span, such as
context.Background(), no longer propagates a trace.GetTraceparent,GetTraceparentW3CandGetBaggagereturn an empty string for it, outgoing HTTP and gRPC requests made with it carry no trace headers, and each event, log and metric captured with it gets its own trace ID. Requests handled by the middleware and contexts fromsentry.WithScopeare unaffected.
// Before: isolate a request hub := sentry.CurrentHub().Clone() hub.Scope().SetTag("route", "checkout") ctx := sentry.SetHubOnContext(r.Context(), hub) hub.CaptureException(err) // After: isolate a request ctx, scope := sentry.WithScope(r.Context()) scope.SetTag("route", "checkout") sentry.CaptureException(ctx, err) // Before: use your own client hub := sentry.NewHub(client, sentry.NewScope()) ctx := sentry.SetHubOnContext(r.Context(), hub) // After: use your own client ctx := sentry.ContextWithClient(r.Context(), client) // Before, in a Gin handler sentrygin.GetHubFromContext(c).CaptureException(err) // After, in a Gin handler sentry.CaptureException(sentrygin.GetContext(c), err)
- The Logrus and Zerolog integrations now take a
context.Context. A client can now be attached to a context withsentry.ContextWithClient, so the separate client-specific constructors are no longer needed. The integrations now use the client initialized fromsentry.Init. by @giortzisg in #1417- Logrus: remove
NewLogHookFromClient,Hook.SetHubProvider,Hook.SetFallbackandFallbackFunc.NewLogHookno longer creates a client or returns an error. - Zerolog: remove
ConfigandNewWithHub. Client options move tosentry.Initorsentry.NewClient.
// Before hook, err := sentrylogrus.NewLogHook(levels, clientOptions) hook := sentrylogrus.NewLogHookFromClient(levels, client) writer, err := sentryzerolog.New(sentryzerolog.Config{ClientOptions: clientOptions, Options: writerOptions}) writer, err := sentryzerolog.NewWithHub(hub, writerOptions) // After: uses the client from sentry.Init hook := sentrylogrus.NewLogHook(ctx, levels) writer, err := sentryzerolog.New(ctx, writerOptions) // After: with a dedicated client ctx = sentry.ContextWithClient(ctx, client) hook := sentrylogrus.NewLogHook(ctx, levels) writer, err := sentryzerolog.New(ctx, writerOptions)
- Logrus: remove
- Add support for Go 1.27 and raise the minimum supported Go version to 1.26 by @giortzisg in #1409
New Features ✨
- (docs) Add migration guide for v1 by @giortzisg in #1457
Internal Changes 🔧
- (deps) Bump golangci-lint to 1.24 by @giortzisg in #1451