diff options
author | Jordan <me@jordan.im> | 2024-01-25 13:11:39 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2024-01-25 13:11:39 -0700 |
commit | 4a7f9719928ed7d42aa3c9e25a327189958983f6 (patch) | |
tree | 7c92b7abfbd0113d16b7d1ccc04bf437e6aedbeb | |
parent | e4c2d6f69b3fa83f5568047c8ae4d0f9ccc62e00 (diff) | |
download | pipkin-4a7f9719928ed7d42aa3c9e25a327189958983f6.tar.gz pipkin-4a7f9719928ed7d42aa3c9e25a327189958983f6.zip |
errors: quiet ECONNRESET and EPIPE errors; they're common and benign
-rw-r--r-- | pipkin.go | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -7,6 +7,7 @@ import ( "encoding/hex" "encoding/json" "encoding/xml" + "errors" "flag" "fmt" "html/template" @@ -17,6 +18,7 @@ import ( "os" "path" "strings" + "syscall" "time" ) @@ -283,10 +285,17 @@ func (pk *Pipkin) fetch(w http.ResponseWriter, r *http.Request) { // Stream response buffer directly to client; memory-efficient over // io.ReadAll(). w.WriteHeader(resp.StatusCode) - _, err = io.Copy(w, resp.Body) - if err != nil { - pk.log.Errorf("Error writing response body: %s %s %s: %s\n", hostStr, - host.Bucket, key, err.Error()) + if _, err = io.Copy(w, resp.Body); err != nil { + if errors.Is(err, syscall.ECONNRESET) { + pk.log.Infof("Connection reset: %s %s %s: %s\n", hostStr, + host.Bucket, key, err.Error()) + } else if errors.Is(err, syscall.EPIPE) { + pk.log.Infof("Broken pipe: %s %s %s: %s\n", hostStr, host.Bucket, + key, err.Error()) + } else { + pk.log.Errorf("Error writing response body: %s %s %s: %s\n", + hostStr, host.Bucket, key, err.Error()) + } } } |