handle read timeout simplification in metrics

This commit is contained in:
oliverpool 2017-02-22 12:22:19 +01:00
parent 338017c9f4
commit 1ce196ed35
1 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package tusd
import (
"net"
"sync"
"sync/atomic"
)
@ -86,8 +87,18 @@ type simpleHTTPError struct {
}
func simplifiedHTTPError(err HTTPError) simpleHTTPError {
var msg string
// Errors for read timeouts contain too much information which is not
// necessary for us and makes grouping for the metrics harder. The error
// message looks like: read tcp 127.0.0.1:1080->127.0.0.1:53673: i/o timeout
// Therefore, we use a common error message for all of them.
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
msg = "read tcp: i/o timeout"
} else {
msg = err.Error()
}
return simpleHTTPError{
Msg: err.Error(),
Msg: msg,
Code: err.StatusCode(),
}
}