代码拉取完成,页面将自动刷新
package impl
import "github.com/prometheus/client_golang/prometheus"
func NewEventCollect() *EventCollect {
return &EventCollect{
errCountDesc: prometheus.NewDesc(
"save_event_error_count",
"事件入库失败个数统计",
[]string{},
prometheus.Labels{"service": "maudit"},
),
}
}
// 收集事件指标的采集器
type EventCollect struct {
errCountDesc *prometheus.Desc
// 需要自己根据实践情况来维护这个变量
errCount int
}
func (c *EventCollect) Inc() {
c.errCount++
}
// 指标元数据注册
func (c *EventCollect) Describe(ch chan<- *prometheus.Desc) {
ch <- c.errCountDesc
}
// 指标的值的采集
func (c *EventCollect) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(c.errCountDesc, prometheus.GaugeValue, float64(c.errCount))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。