handle read timeout simplification in metrics
This commit is contained in:
parent
338017c9f4
commit
1ce196ed35
13
metrics.go
13
metrics.go
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue