add labels to logged errors (#2824)

#### Does this PR need a docs update or release note?

- [x]  No

#### Type of change

- [x] 🧹 Tech Debt/Cleanup
This commit is contained in:
Keepers 2023-03-20 15:12:05 -06:00 committed by GitHub
parent c47ee74837
commit 8b1c3a7073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -284,7 +284,9 @@ func Ctx(ctx context.Context) *zap.SugaredLogger {
// and packs all of the structured data in the error inside it. // and packs all of the structured data in the error inside it.
func CtxErr(ctx context.Context, err error) *zap.SugaredLogger { func CtxErr(ctx context.Context, err error) *zap.SugaredLogger {
return Ctx(ctx). return Ctx(ctx).
With("error", err). With(
"error", err,
"error_labels", clues.Labels(err)).
With(clues.InErr(err).Slice()...) With(clues.InErr(err).Slice()...)
} }