当我从其他go进程调用inc(),add()时,度量标准值不会更新。
server.go
package main
import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"net/http"
)
func main() {
http.Handle("/metrics", promhttp.Handler())
log.Infoln("Metrics Server Started at 7189")
log.Fatal(http.ListenAndServe(":7189", nil))
}
metrics.go
package main
import "github.com/prometheus/client_golang/prometheus"
var JobGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "queue",
Name: "no_of_live_jobs",
Help: "This value gives number of of jobs in queue",
})
func init() {
prometheus.MustRegister(JobGauge)
JobGauge.Set(0)
}
client.go
package main
func main() {
JobGauge.Add(10)
}
当我确实从server.go
的量规中增加了价值时,它的工作效果很好。但是,当我从client.go
添加要测量的值时,该值没有被添加。我在这里想念什么?
先谢谢了。