mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-04 15:12:26 +08:00
up
This commit is contained in:
@@ -12,6 +12,9 @@ var errSkip = errors.New(`skip`)
|
||||
// WebHandle ...
|
||||
func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
metrics.ReqConcurrentInc()
|
||||
defer metrics.ReqConcurrentDec()
|
||||
|
||||
p, err := req(w, r)
|
||||
if err != nil {
|
||||
if err != errSkip {
|
||||
|
||||
@@ -10,6 +10,12 @@ var (
|
||||
reqCount = newCounter(`orca_req_count`, `HTTP 请求次数`)
|
||||
reqFailCount = newCounter(`orca_req_fail_count`, `无法响应的 HTTP 请求数`)
|
||||
reqBytes = newCounter(`orca_req_bytes`, `文件总上传量`)
|
||||
reqConcurrent = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: `orca_req_concurrent`,
|
||||
Help: `当前并发请求数`,
|
||||
},
|
||||
)
|
||||
errorCount = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: `orca_error_code`,
|
||||
@@ -24,6 +30,16 @@ func ReqFailCount() {
|
||||
reqFailCount.Inc()
|
||||
}
|
||||
|
||||
// ReqConcurrentInc ...
|
||||
func ReqConcurrentInc() {
|
||||
reqConcurrent.Inc()
|
||||
}
|
||||
|
||||
// ReqConcurrentDec ...
|
||||
func ReqConcurrentDec() {
|
||||
reqConcurrent.Dec()
|
||||
}
|
||||
|
||||
// ReqBytes ...
|
||||
func ReqBytes(n int) {
|
||||
reqCount.Inc()
|
||||
|
||||
@@ -6,6 +6,8 @@ func init() {
|
||||
prometheus.MustRegister(reqCount)
|
||||
prometheus.MustRegister(reqFailCount)
|
||||
prometheus.MustRegister(reqBytes)
|
||||
prometheus.MustRegister(reqConcurrent)
|
||||
|
||||
prometheus.MustRegister(errorCount)
|
||||
|
||||
prometheus.MustRegister(rspBytes)
|
||||
|
||||
Reference in New Issue
Block a user