From 7cacfad29b6fadadf65e1a21cabbb9320d8a2528 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Tue, 19 May 2020 18:43:59 +0200 Subject: [PATCH] all: Adapt to sentry package API changes Refs https://github.com/getsentry/sentry-go/pull/168 --- pkg/errors/web/middleware.go | 2 +- pkg/rpcmiddleware/sentry/sentry.go | 4 +++- pkg/webhandlers/error.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/errors/web/middleware.go b/pkg/errors/web/middleware.go index 1b0c4fc180..f764b9fa87 100644 --- a/pkg/errors/web/middleware.go +++ b/pkg/errors/web/middleware.go @@ -100,7 +100,7 @@ func ErrorMiddleware(extraRenderers map[string]ErrorRenderer) echo.MiddlewareFun if statusCode >= 500 { errEvent := sentryerrors.NewEvent(err) errEvent.Transaction = c.Path() - errEvent.Request = errEvent.Request.FromHTTPRequest(c.Request()) + errEvent.Request = sentry.NewRequest(c.Request()) sentry.CaptureEvent(errEvent) } if c.Response().Committed { diff --git a/pkg/rpcmiddleware/sentry/sentry.go b/pkg/rpcmiddleware/sentry/sentry.go index 0b9c2137fe..01ff2a0dab 100644 --- a/pkg/rpcmiddleware/sentry/sentry.go +++ b/pkg/rpcmiddleware/sentry/sentry.go @@ -23,7 +23,6 @@ import ( "github.com/getsentry/sentry-go" grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" "go.thethings.network/lorawan-stack/v3/pkg/errors" - sentryerrors "go.thethings.network/lorawan-stack/v3/pkg/errors/sentry" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -49,6 +48,9 @@ func reportError(ctx context.Context, method string, err error) { // Request Tags. errEvent.Transaction = method + if errEvent.Request == nil { + errEvent.Request = &sentry.Request{} + } errEvent.Request.URL = method errEvent.Request.Headers = make(map[string]string) errEvent.Tags["grpc.method"] = method diff --git a/pkg/webhandlers/error.go b/pkg/webhandlers/error.go index c497cfd31a..515e7ef07c 100644 --- a/pkg/webhandlers/error.go +++ b/pkg/webhandlers/error.go @@ -51,7 +51,7 @@ func Error(w http.ResponseWriter, r *http.Request, err error) { code, err := weberrors.ProcessError(err) if code >= 500 { errEvent := sentryerrors.NewEvent(err) - errEvent.Request = errEvent.Request.FromHTTPRequest(r) + errEvent.Request = sentry.NewRequest(r) sentry.CaptureEvent(errEvent) } if errPtr, ok := r.Context().Value(errorContextValue).(*error); ok && errPtr != nil {