Skip to content

Commit

Permalink
Add log in frontend API for InternalServiceError (#548)
Browse files Browse the repository at this point in the history
* Add log in frontend API for InternalServiceError

* Use TagErr instead
  • Loading branch information
vancexu authored Feb 10, 2018
1 parent 083cb3c commit 86e5954
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/logging/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ func LogOperationPanicEvent(logger bark.Logger, msg string, err error) {
}).Fatalf("%v. Error: %v", msg, err)
}

// LogInternalServiceError is used to log internal service error
func LogInternalServiceError(logger bark.Logger, err error) {
logger.WithFields(bark.Fields{
TagErr: err,
}).Error("Internal service error")
}

// LogUncategorizedError is used to log error that are uncategorized
func LogUncategorizedError(logger bark.Logger, err error) {
logger.WithFields(bark.Fields{
TagErr: err,
}).Error("Uncategorized error")
}

//
// History service logging methods
//
Expand Down
2 changes: 2 additions & 0 deletions service/frontend/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@ func (wh *WorkflowHandler) startRequestProfile(scope int) tally.Stopwatch {
func (wh *WorkflowHandler) error(err error, scope int) error {
switch err.(type) {
case *gen.InternalServiceError:
logging.LogInternalServiceError(wh.Service.GetLogger(), err)
wh.metricsClient.IncCounter(scope, metrics.CadenceFailures)
return err
case *gen.BadRequestError:
Expand All @@ -1702,6 +1703,7 @@ func (wh *WorkflowHandler) error(err error, scope int) error {
wh.metricsClient.IncCounter(scope, metrics.CadenceErrQueryFailedCounter)
return err
default:
logging.LogUncategorizedError(wh.Service.GetLogger(), err)
wh.metricsClient.IncCounter(scope, metrics.CadenceFailures)
return &gen.InternalServiceError{Message: err.Error()}
}
Expand Down

0 comments on commit 86e5954

Please sign in to comment.