[#426] engine: Support duration metrics

With `enable metrics` option, engine will collect
durations for all public methods.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-03-15 16:09:27 +03:00 committed by Leonard Lyubich
parent bc6e7a823b
commit 980b774af2
12 changed files with 169 additions and 0 deletions

View file

@ -48,6 +48,10 @@ func (r *SelectRes) AddressList() []*object.Address {
//
// Returns any error encountered that did not allow to completely select the objects.
func (e *StorageEngine) Select(prm *SelectPrm) (*SelectRes, error) {
if e.enableMetrics {
defer elapsed(searchDuration)()
}
addrList := make([]*object.Address, 0)
uniqueMap := make(map[string]struct{})
@ -94,6 +98,10 @@ func (e *StorageEngine) Select(prm *SelectPrm) (*SelectRes, error) {
// List returns `limit` available physically storage object addresses in engine.
// If limit is zero, then returns all available object addresses.
func (e *StorageEngine) List(limit uint64) (*SelectRes, error) {
if e.enableMetrics {
defer elapsed(listObjectsDuration)()
}
addrList := make([]*object.Address, limit)
uniqueMap := make(map[string]struct{})
ln := uint64(0)