Record timestamp when a context was cancelled (#1018)

This commit is contained in:
Miccah 2023-01-13 12:21:09 -06:00 committed by GitHub
parent 0aa8e1cd98
commit 45b02f46d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()),
)
}
}