mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 08:46:48 +00:00
Log fork/duration
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
38a3843d62
commit
8314b3c0b5
@ -60,6 +60,8 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
debugHeaders(&r.Header, "in")
|
debugHeaders(&r.Header, "in")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Forking fprocess.")
|
||||||
|
|
||||||
targetCmd := exec.Command(parts[0], parts[1:]...)
|
targetCmd := exec.Command(parts[0], parts[1:]...)
|
||||||
|
|
||||||
envs := getAdditionalEnvs(config, r, method)
|
envs := getAdditionalEnvs(config, r, method)
|
||||||
@ -160,10 +162,11 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bytesWritten string
|
||||||
if config.writeDebug == true {
|
if config.writeDebug == true {
|
||||||
os.Stdout.Write(out)
|
os.Stdout.Write(out)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Wrote %d Bytes\n", len(out))
|
bytesWritten = fmt.Sprintf("Wrote %d Bytes", len(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.contentType) > 0 {
|
if len(config.contentType) > 0 {
|
||||||
@ -177,8 +180,8 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
execTime := time.Since(startTime).Seconds()
|
||||||
if ri.headerWritten == false {
|
if ri.headerWritten == false {
|
||||||
execTime := time.Since(startTime).Seconds()
|
|
||||||
w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", execTime))
|
w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", execTime))
|
||||||
ri.headerWritten = true
|
ri.headerWritten = true
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
@ -189,6 +192,11 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
header := w.Header()
|
header := w.Header()
|
||||||
debugHeaders(&header, "out")
|
debugHeaders(&header, "out")
|
||||||
}
|
}
|
||||||
|
if len(bytesWritten) > 0 {
|
||||||
|
log.Printf("%s - Duration: %f seconds", bytesWritten, execTime)
|
||||||
|
} else {
|
||||||
|
log.Printf("Duration: %f seconds", execTime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAdditionalEnvs(config *WatchdogConfig, r *http.Request, method string) []string {
|
func getAdditionalEnvs(config *WatchdogConfig, r *http.Request, method string) []string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user