Skip to content

Commit

Permalink
Improve Sentry error message for failed queries
Browse files Browse the repository at this point in the history
  • Loading branch information
anbsky committed Oct 10, 2019
1 parent 7647c33 commit c27cff2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/monitor/sentry.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package monitor

import (
"errors"
"fmt"

"github.com/lbryio/lbrytv/config"
Expand Down Expand Up @@ -45,10 +44,12 @@ func CaptureException(err error, params ...map[string]string) {

// captureFailedQuery sends to Sentry details of a failed daemon call.
func captureFailedQuery(method string, query interface{}, errorResponse interface{}) {
sentry.WithScope(func(scope *sentry.Scope) {
scope.SetExtra("method", method)
scope.SetExtra("query", fmt.Sprintf("%v", query))
scope.SetExtra("response", fmt.Sprintf("%v", errorResponse))
sentry.CaptureException(errors.New("Daemon responded with an error"))
})
CaptureException(
fmt.Errorf("daemon responded with an error when calling method %v", method),
map[string]string{
"method": method,
"query": fmt.Sprintf("%v", query),
"response": fmt.Sprintf("%v", errorResponse),
},
)
}

0 comments on commit c27cff2

Please sign in to comment.