Skip to content

Migrate to sentry-go

Steve Xuereb requested to merge 5-upgrade-to-sentry-go into master

Overview

The github.com/getsentry/raven-go was deprecated in favor of github.com/getsentry/sentry-go. Update the dependency to the latest a version of github.com/getsentry/sentry-go and remove raven-go as a dependency, following the migration guide.

This update does not break any downstream clients to keep backward compatibility. We cannot completely remove the raven-go dependency since we have correlation/raven package (deprecated) that exposes raven specific information.

Testing

I've used the following code snippet to test the changes in labkit

main.go
func main() {
	errortracking.Initialize(errortracking.WithSentryDSN("https://0f1ec4d29b3e4172ae8a8554f5a2efbb@sentry.io/1467104"))

	req, err := http.NewRequest("GET", "http://example.com?test=here", nil)
	ctx := labkitctx.ContextWithCorrelation(req.Context(), "thisIsContextID")

	req.Header.Add("test", "another")

	err = errors.New("some error")

	// Send the error to the error tracking system
	errortracking.Capture(err,
		errortracking.WithContext(ctx),                          // Extract details such as correlation-id from context
		errortracking.WithRequest(req),                          // Extract additional details from request
		errortracking.WithField("domain", "http://example.com"), // Add additional custom details
		errortracking.WithField("steve", "test"),
	)

	time.Sleep(time.Minute)
}

If we look at the screenshot below the new sentry-go library finds more information out of the box as well.

raven-go sentry-go
Screen_Shot_2019-11-17_at_11.43.05 Screen_Shot_2019-11-17_at_11.43.13 Screen_Shot_2019-11-17_at_11.37.31 Screen_Shot_2019-11-17_at_11.37.40

Breaking Change 💥

We had to change the signature of CapatureOption since we can't use the old raven structs for this.

If anyone using the default CaptureOption that we provide they will not see any changes, but if they build their own CaptureOption this will break since the signature changed.

Closes #5 (closed)

Edited by Steve Xuereb

Merge request reports