From 45b02f46d997b605eafb0cc4e1d02e13ede9a4da Mon Sep 17 00:00:00 2001 From: Miccah Date: Fri, 13 Jan 2023 12:21:09 -0600 Subject: [PATCH] Record timestamp when a context was cancelled (#1018) --- pkg/context/context.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/context/context.go b/pkg/context/context.go index ff4de39c..ef0df108 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -166,6 +166,9 @@ func captureCancelCallstack(ctx logCtx, f context.CancelFunc) (Context, context. } f() // Set the error with the stacktrace if the err pointer is non-nil. - *ctx.err = fmt.Errorf("%w (%s)", ctx.Err(), string(debug.Stack())) + *ctx.err = fmt.Errorf( + "%w (canceled at %v\n%s)", + ctx.Err(), time.Now(), string(debug.Stack()), + ) } }