Instrument with less labels and more focused metrics
This commit is contained in:
parent
455fb65e77
commit
ab9c5281a5
2 changed files with 33 additions and 11 deletions
|
@ -18,6 +18,8 @@ const (
|
|||
type promInst struct {
|
||||
visits *prometheus.CounterVec
|
||||
reqDur *prometheus.HistogramVec
|
||||
search *prometheus.CounterVec
|
||||
searchDur *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
func Init() Instrument {
|
||||
|
@ -28,7 +30,7 @@ func Init() Instrument {
|
|||
Name: "trantor_visits_total",
|
||||
Help: "Number of visits.",
|
||||
},
|
||||
[]string{"section", "id", "search", "fmt"},
|
||||
[]string{"section"},
|
||||
)
|
||||
reqDur := prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
|
@ -37,13 +39,31 @@ func Init() Instrument {
|
|||
},
|
||||
[]string{"section"},
|
||||
)
|
||||
search := prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "trantor_search_total",
|
||||
Help: "Number of searches.",
|
||||
},
|
||||
[]string{"search"},
|
||||
)
|
||||
searchDur := prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "trantor_search_duration_seconds",
|
||||
Help: "Duration of the search in seconds.",
|
||||
},
|
||||
[]string{"search"},
|
||||
)
|
||||
|
||||
prometheus.MustRegister(visits)
|
||||
prometheus.MustRegister(reqDur)
|
||||
prometheus.MustRegister(search)
|
||||
prometheus.MustRegister(searchDur)
|
||||
|
||||
return &promInst{
|
||||
visits: visits,
|
||||
reqDur: reqDur,
|
||||
search: search,
|
||||
searchDur: searchDur,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +76,8 @@ func promHandle() {
|
|||
}
|
||||
|
||||
func (in promInst) Request(req RequestData) {
|
||||
in.visits.WithLabelValues(req.Section, req.ID, req.Search, req.Fmt).Inc()
|
||||
in.visits.WithLabelValues(req.Section).Inc()
|
||||
in.reqDur.WithLabelValues(req.Section).Observe(req.Duration.Seconds())
|
||||
in.search.WithLabelValues(req.Search).Inc()
|
||||
in.searchDur.WithLabelValues(req.Search).Set(req.Duration.Seconds())
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func (sg StatsGatherer) worker() {
|
|||
ID: id,
|
||||
Search: search,
|
||||
Fmt: fmt,
|
||||
Duration: req.duration
|
||||
Duration: req.duration,
|
||||
})
|
||||
switch section {
|
||||
case "download":
|
||||
|
|
Reference in a new issue