internal/gitserver: Instrument calls to AddrForRepo (#24636)

This commit is contained in:
Indradhanush Gupta 2021-09-06 19:36:50 +05:30 committed by GitHub
parent 8d79eab74a
commit ca98cfc4bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,9 +96,16 @@ func (c *Client) addrForKey(key string) string {
return addrForKey(key, addrs)
}
var addForRepoInvoked = promauto.NewCounter(prometheus.CounterOpts{
Name: "src_gitserver_addr_for_repo_invoked",
Help: "Number of times gitserver.AddrForRepo was invoked",
})
// AddrForRepo returns the gitserver address to use for the given repo name.
// It should never be called with an empty slice.
func AddrForRepo(repo api.RepoName, addrs []string) string {
addForRepoInvoked.Inc()
repo = protocol.NormalizeRepo(repo) // in case the caller didn't already normalize it
return addrForKey(string(repo), addrs)
}