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