mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-02-07 11:36:25 +02:00
Add info to timers
This commit is contained in:
parent
ec627e3345
commit
f569067588
@ -142,7 +142,7 @@ func checkSecret(s string) bool {
|
||||
}
|
||||
|
||||
func (h *httpHandler) lock() {
|
||||
t := startTimer(time.Duration(conf.WaitTimeout) * time.Second)
|
||||
t := startTimer(time.Duration(conf.WaitTimeout)*time.Second, "Waiting")
|
||||
|
||||
select {
|
||||
case h.sem <- struct{}{}:
|
||||
@ -173,7 +173,7 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
panic(invalidSecretErr)
|
||||
}
|
||||
|
||||
t := startTimer(time.Duration(conf.WriteTimeout) * time.Second)
|
||||
t := startTimer(time.Duration(conf.WriteTimeout)*time.Second, "Processing")
|
||||
|
||||
h.lock()
|
||||
defer h.unlock()
|
||||
|
7
timer.go
7
timer.go
@ -8,10 +8,11 @@ import (
|
||||
type timer struct {
|
||||
StartTime time.Time
|
||||
Timer <-chan time.Time
|
||||
Info string
|
||||
}
|
||||
|
||||
func startTimer(dt time.Duration) *timer {
|
||||
return &timer{time.Now(), time.After(dt)}
|
||||
func startTimer(dt time.Duration, info string) *timer {
|
||||
return &timer{time.Now(), time.After(dt), info}
|
||||
}
|
||||
|
||||
func (t *timer) Check() {
|
||||
@ -24,7 +25,7 @@ func (t *timer) Check() {
|
||||
}
|
||||
|
||||
func (t *timer) TimeoutErr() imgproxyError {
|
||||
return newError(503, fmt.Sprintf("Timeout after %v", t.Since()), "Timeout")
|
||||
return newError(503, fmt.Sprintf("Timeout after %v (%s)", t.Since(), t.Info), "Timeout")
|
||||
}
|
||||
|
||||
func (t *timer) Since() time.Duration {
|
||||
|
Loading…
x
Reference in New Issue
Block a user