thoas / stats

A Go middleware that stores various information about your web application (response time, status code count, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use martini status_code_count and total_status_code_count code question,

DavidYangNO1 opened this issue · comments

{
"pid": 27613,
"uptime": "2m7.358545583s",
"uptime_sec": 127.358545583,
"time": "2016-11-10 14:45:35.526270515 +0800 CST",
"unixtime": 1478760335,
"status_code_count": {
"200": 1
},
"total_status_code_count": {
"200": 17
},
"count": 1,
"total_count": 17,
"total_response_time": "78.531534ms",
"total_response_time_sec": 0.078531534,
"average_response_time": "4.619502ms",
"average_response_time_sec": 0.004619502
}

status_code_count and total_status_code_count code always 200, reivew the code , it is hard-coded. so I think the statecode should be depend on w.
func (mw *Stats) Begin(w http.ResponseWriter) (time.Time, ResponseWriter) {
start := time.Now()

writer := NewRecorderResponseWriter(w, 200)

return start, writer

}

I've just taken a look at this project, found the same problem and I agree with David. The hardcoded 200 at https://github.com/thoas/stats/blob/master/stats.go#L73 means that stats are only collected for 200.