aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2024-01-25 13:11:39 -0700
committerJordan <me@jordan.im>2024-01-25 13:11:39 -0700
commit4a7f9719928ed7d42aa3c9e25a327189958983f6 (patch)
tree7c92b7abfbd0113d16b7d1ccc04bf437e6aedbeb
parente4c2d6f69b3fa83f5568047c8ae4d0f9ccc62e00 (diff)
downloadpipkin-4a7f9719928ed7d42aa3c9e25a327189958983f6.tar.gz
pipkin-4a7f9719928ed7d42aa3c9e25a327189958983f6.zip
errors: quiet ECONNRESET and EPIPE errors; they're common and benign
-rw-r--r--pipkin.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/pipkin.go b/pipkin.go
index 575d22e..556a493 100644
--- a/pipkin.go
+++ b/pipkin.go
@@ -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())
+ }
}
}