api prommetrics

pull/2398/head
withchao 1 year ago
parent 6713986887
commit 9151b56fe9

@ -28,9 +28,9 @@ func prommetricsGin() gin.HandlerFunc {
//prommetrics.HttpCall(path, c.Request.Method, c.Writer.Status(), time.Since(start))
if c.Request.Method == http.MethodPost {
if resp := apiresp.GetGinApiResponse(c); resp == nil {
prommetrics.APICall(path, -1, "NO_GIN_RESPONSE_FOUND")
prommetrics.APICall(path, -1)
} else {
prommetrics.APICall(path, resp.ErrCode, resp.ErrMsg)
prommetrics.APICall(path, resp.ErrCode)
}
}
}

@ -17,7 +17,7 @@ var (
Name: "api_count",
Help: "Total number of API calls",
},
[]string{"path", "code", "type"},
[]string{"path", "code"},
)
httpCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
@ -33,8 +33,8 @@ func init() {
apiRegistry.MustRegister(apiCounter, httpCounter)
}
func APICall(path string, apiCode int, apiType string) {
apiCounter.With(prometheus.Labels{"path": path, "code": strconv.Itoa(apiCode), "type": apiType}).Inc()
func APICall(path string, apiCode int) {
apiCounter.With(prometheus.Labels{"path": path, "code": strconv.Itoa(apiCode)}).Inc()
}
//func HttpCall(path string, method string, status int, duration time.Duration) {

Loading…
Cancel
Save