Let's instrument the search string with the duration
This commit is contained in:
parent
5eca3843cc
commit
c6354c46c8
4 changed files with 7 additions and 7 deletions
|
@ -10,5 +10,5 @@ func Init() Instrument {
|
|||
return &dummyInst{}
|
||||
}
|
||||
|
||||
func (i dummyInst) Visit(section string, id string, search string, fmt string) {}
|
||||
func (i dummyInst) Duration(section string, duration time.Duration) {}
|
||||
func (i dummyInst) Visit(section string, id string, search string, fmt string) {}
|
||||
func (i dummyInst) Duration(section string, search string, duration time.Duration) {}
|
||||
|
|
|
@ -4,5 +4,5 @@ import "time"
|
|||
|
||||
type Instrument interface {
|
||||
Visit(section string, id string, search string, fmt string)
|
||||
Duration(section string, duration time.Duration)
|
||||
Duration(section string, search string, duration time.Duration)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func Init() Instrument {
|
|||
Name: "trantor_request_duration_seconds",
|
||||
Help: "Duration of the request in seconds.",
|
||||
},
|
||||
[]string{"section"},
|
||||
[]string{"section", "search"},
|
||||
)
|
||||
|
||||
prometheus.MustRegister(visits)
|
||||
|
@ -61,6 +61,6 @@ func (in promInst) Visit(section string, id string, search string, fmt string) {
|
|||
in.visits.WithLabelValues(section, id, search, fmt).Inc()
|
||||
}
|
||||
|
||||
func (in promInst) Duration(section string, duration time.Duration) {
|
||||
in.reqDur.WithLabelValues(section).Observe(duration.Seconds())
|
||||
func (in promInst) Duration(section string, search string, duration time.Duration) {
|
||||
in.reqDur.WithLabelValues(section, search).Observe(duration.Seconds())
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ func (sg StatsGatherer) worker() {
|
|||
}
|
||||
|
||||
sg.instrument.Visit(section, id, search, fmt)
|
||||
sg.instrument.Duration(section, req.duration*time.Microsecond)
|
||||
sg.instrument.Duration(section, search, req.duration)
|
||||
switch section {
|
||||
case "download":
|
||||
err = sg.db.IncDownloads(id)
|
||||
|
|
Reference in a new issue