Skip to content

Commit

Permalink
all: Adapt to sentry package API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Volosatovs committed May 19, 2020
1 parent 7f85a69 commit 7cacfad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/errors/web/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion pkg/rpcmiddleware/sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhandlers/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7cacfad

Please sign in to comment.