[#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:
parent
bc6e7a823b
commit
980b774af2
12 changed files with 169 additions and 0 deletions
|
@ -38,6 +38,10 @@ func (r *ListContainersRes) Containers() []*container.ID {
|
|||
|
||||
// ContainerSize returns sum of estimation container sizes among all shards.
|
||||
func (e *StorageEngine) ContainerSize(prm *ContainerSizePrm) *ContainerSizeRes {
|
||||
if e.enableMetrics {
|
||||
defer elapsed(estimateContainerSizeDuration)()
|
||||
}
|
||||
|
||||
return &ContainerSizeRes{
|
||||
size: e.containerSize(prm.cid),
|
||||
}
|
||||
|
@ -70,6 +74,10 @@ func (e *StorageEngine) containerSize(id *container.ID) (total uint64) {
|
|||
|
||||
// ListContainers returns unique container IDs presented in the engine objects.
|
||||
func (e *StorageEngine) ListContainers(_ *ListContainersPrm) *ListContainersRes {
|
||||
if e.enableMetrics {
|
||||
defer elapsed(listContainersDuration)()
|
||||
}
|
||||
|
||||
return &ListContainersRes{
|
||||
containers: e.listContainers(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue