Skip to content

Commit

Permalink
don't log errors from within backoff loop
Browse files Browse the repository at this point in the history
Signed-off-by: David Grove <groved@us.ibm.com>
  • Loading branch information
dgrove-oss committed Jun 5, 2023
1 parent e56affb commit 284ec87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/internal/runtime/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func invoke(ctx context.Context, method string, msg map[string]string, metricLab
var res *http.Response
start := time.Now()
res, err = client.Do(req)
elapsed := time.Now().Sub(start)
elapsed := time.Since(start)
if metricLabel != "" {
userCodeDurationHistogram.WithLabelValues(metricLabel).Observe(elapsed.Seconds())
}
Expand All @@ -130,7 +130,6 @@ func invoke(ctx context.Context, method string, msg map[string]string, metricLab
reply = &Reply{StatusCode: http.StatusRequestTimeout, Payload: err.Error(), ContentType: "text/plain"}
return nil
}
logger.Warning("failed to invoke %s: %v", msg["path"], err)
if err == ctx.Err() {
return backoff.Permanent(err)
}
Expand All @@ -142,7 +141,6 @@ func invoke(ctx context.Context, method string, msg map[string]string, metricLab
reply = &Reply{StatusCode: http.StatusRequestTimeout, Payload: err.Error(), ContentType: "text/plain"}
return nil
}
logger.Warning("failed to invoke %s: %v", msg["path"], err)
if err == ctx.Err() {
return backoff.Permanent(err)
}
Expand All @@ -159,6 +157,9 @@ func invoke(ctx context.Context, method string, msg map[string]string, metricLab
if ctx.Err() != nil {
CloseIdleConnections() // don't keep connection alive once ctx is cancelled
}
if err != nil && err != ctx.Err() {
logger.Warning("failed to invoke %s: %v", msg["path"], err)
}
return reply, err
}

Expand Down

0 comments on commit 284ec87

Please sign in to comment.