From bce7131d9f01f7aa9e540b47ab5b6cb85c59f799 Mon Sep 17 00:00:00 2001 From: ayflying Date: Wed, 2 Apr 2025 15:55:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=90=AFqps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/aycache/cache.go | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/pkg/aycache/cache.go b/pkg/aycache/cache.go index cb685db..fa32634 100644 --- a/pkg/aycache/cache.go +++ b/pkg/aycache/cache.go @@ -1,9 +1,15 @@ package aycache import ( + v1 "github.com/ayflying/utility_go/api/system/v1" + "github.com/ayflying/utility_go/internal/boot" "github.com/ayflying/utility_go/pkg/aycache/drive" drive2 "github.com/ayflying/utility_go/pkg/aycache/drive" + "github.com/ayflying/utility_go/service" "github.com/gogf/gf/v2/os/gcache" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" + "math" ) type Mod struct { @@ -12,23 +18,23 @@ type Mod struct { var ( QPSCount int - //QPS = promauto.NewGauge( - // prometheus.GaugeOpts{ - // Name: "Cache_QPS", - // Help: "当前缓存QPS数量", - // }, - //) + QPS = promauto.NewGauge( + prometheus.GaugeOpts{ + Name: "Cache_QPS", + Help: "当前缓存QPS数量", + }, + ) ) func init() { - //boot.AddFunc(func() { - // //初始化指标 - // service.SystemCron().AddCron(v1.CronType_MINUTE, func() error { - // QPS.Set(math.Round(float64(QPSCount) / 60)) - // QPSCount = 0 - // return nil - // }) - //}) + boot.AddFunc(func() { + //初始化指标 + service.SystemCron().AddCron(v1.CronType_MINUTE, func() error { + QPS.Set(math.Round(float64(QPSCount) / 60)) + QPSCount = 0 + return nil + }) + }) }