1 Star 1 Fork 0

ayun2001 / ok-boost-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
prometheus.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
李盛雁 提交于 2023-08-09 16:45 . 开发中
package rewrite
import (
"gitee.com/ayun2001/ok-boost-go/http/server/common"
"gitee.com/ayun2001/ok-boost-go/pkg/utils"
"github.com/prometheus/client_golang/prometheus"
)
type pathRewriterMetrics struct {
rewriteCount *prometheus.CounterVec
}
func newPathRewriteMetrics() *pathRewriterMetrics {
return &pathRewriterMetrics{}
}
func (p *pathRewriterMetrics) registerMetrics() {
var metricLabels = []string{"method", "path", "rewritePath", "app", common.ConstPromServiceEndpoint}
var id = utils.GetRandIdString()
p.rewriteCount = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: utils.ConstDefaultPrometheusNamespace,
Subsystem: utils.ConstDefaultPrometheusSubsystemName,
Name: "http_server_request_path_rewrite_count",
Help: "The total number of HTTP request paths rewrited.",
ConstLabels: map[string]string{"id": id},
}, metricLabels,
)
prometheus.MustRegister(p.rewriteCount)
}
func (p *pathRewriterMetrics) unRegisterMetrics() {
prometheus.Unregister(p.rewriteCount)
}
Go
1
https://gitee.com/ayun2001/ok-boost-go.git
git@gitee.com:ayun2001/ok-boost-go.git
ayun2001
ok-boost-go
ok-boost-go
d07672de674d

搜索帮助