-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add request handling statistics for pouch daemon
Signed-off-by: Allen Sun <allensun.shl@alibaba-inc.com>
- Loading branch information
1 parent
33d90d2
commit 1ee251a
Showing
5 changed files
with
215 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package server | ||
|
||
import "sync" | ||
|
||
// RequestStats is the request dealing result, | ||
// including all handled request number, 2xx3xx number, 4xx number and 5xx number | ||
type RequestStats struct { | ||
sync.Mutex | ||
// req5xxCount is the count number of failed request which returns a status code of 5xx. | ||
req5xxCount uint64 | ||
// req4xxCount is the count number of failed request which returns a status code of 5xx. | ||
req4xxCount uint64 | ||
// req2xxCount is the count number of requests which returns a status code of 2xx and 3xx. | ||
req2xx3xxCount uint64 | ||
// reqCount is the count number of all request. | ||
reqCount uint64 | ||
} | ||
|
||
func (rs *RequestStats) getAllCount() uint64 { | ||
rs.Lock() | ||
defer rs.Unlock() | ||
return rs.reqCount | ||
} | ||
|
||
func (rs *RequestStats) get2xx3xxCount() uint64 { | ||
rs.Lock() | ||
defer rs.Unlock() | ||
return rs.req2xx3xxCount | ||
} | ||
|
||
func (rs *RequestStats) get4xxCount() uint64 { | ||
rs.Lock() | ||
defer rs.Unlock() | ||
return rs.req4xxCount | ||
} | ||
|
||
func (rs *RequestStats) get5xxCount() uint64 { | ||
rs.Lock() | ||
defer rs.Unlock() | ||
return rs.req5xxCount | ||
} | ||
|
||
func (rs *RequestStats) increaseReqCount() { | ||
rs.Lock() | ||
rs.reqCount++ | ||
rs.Unlock() | ||
} | ||
|
||
func (rs *RequestStats) increase2xx3xxCount() { | ||
rs.Lock() | ||
rs.req2xx3xxCount++ | ||
rs.Unlock() | ||
} | ||
|
||
func (rs *RequestStats) increase4xxCount() { | ||
rs.Lock() | ||
rs.req4xxCount++ | ||
rs.Unlock() | ||
} | ||
|
||
func (rs *RequestStats) increase5xxCount() { | ||
rs.Lock() | ||
rs.req5xxCount++ | ||
rs.Unlock() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters