do not log client canceled events (#17838)

This commit is contained in:
Harshavardhana 2023-08-17 14:53:43 -07:00 committed by GitHub
parent dde1a12819
commit 11dfc817f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -377,7 +377,11 @@ func (h *Target) Send(ctx context.Context, entry interface{}) error {
select {
case h.logCh <- entry:
case <-ctx.Done():
return ctx.Err()
// return error only for context timedout.
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
return ctx.Err()
}
return nil
default:
nWorkers := atomic.LoadInt64(&h.workers)
if nWorkers < maxWorkers {

View File

@ -330,6 +330,12 @@ func (h *Target) Send(ctx context.Context, entry interface{}) error {
select {
case h.logCh <- entry:
case <-ctx.Done():
// return error only for context timedout.
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
return ctx.Err()
}
return nil
default:
// log channel is full, do not wait and return
// an error immediately to the caller