From 86e59542602c089902111ce1c6089096e9116850 Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Fri, 9 Feb 2018 16:04:25 -0800 Subject: [PATCH] Add log in frontend API for InternalServiceError (#548) * Add log in frontend API for InternalServiceError * Use TagErr instead --- common/logging/helpers.go | 14 ++++++++++++++ service/frontend/handler.go | 2 ++ 2 files changed, 16 insertions(+) diff --git a/common/logging/helpers.go b/common/logging/helpers.go index 9e98d17cc73..5d8a7483576 100644 --- a/common/logging/helpers.go +++ b/common/logging/helpers.go @@ -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 // diff --git a/service/frontend/handler.go b/service/frontend/handler.go index d131d2072c2..d9ed1651506 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -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: @@ -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()} }