Skip to content

Commit

Permalink
feat: improve metric (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq authored Feb 14, 2022
1 parent 36c806c commit 0353fe6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pkg/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"time"

"github.com/douyu/jupiter/pkg"
"github.com/douyu/jupiter/pkg/conf"
"github.com/douyu/jupiter/pkg/constant"
"github.com/douyu/jupiter/pkg/governor"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -148,15 +149,17 @@ var (
)

func init() {
BuildInfoGauge.WithLabelValues(
pkg.Name(),
pkg.AppID(),
pkg.AppMode(),
pkg.AppRegion(),
pkg.AppZone(),
pkg.AppVersion(),
pkg.GoVersion(),
).Set(float64(time.Now().UnixNano() / 1e6))
conf.OnLoaded(func(c *conf.Configuration) {
BuildInfoGauge.WithLabelValues(
pkg.Name(),
pkg.AppID(),
pkg.AppMode(),
pkg.AppRegion(),
pkg.AppZone(),
pkg.AppVersion(),
pkg.GoVersion(),
).Set(float64(time.Now().UnixNano() / 1e6))
})

governor.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
promhttp.Handler().ServeHTTP(w, r)
Expand Down

0 comments on commit 0353fe6

Please sign in to comment.