forked from TrueCloudLab/frostfs-sdk-go
Add intermediate metrics
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
58ef4a1014
commit
64dc65b666
4 changed files with 128 additions and 6 deletions
|
@ -1155,6 +1155,7 @@ func (c *clientStatusMonitor) methodsStatus() []StatusSnapshot {
|
||||||
result := make([]StatusSnapshot, len(c.methods))
|
result := make([]StatusSnapshot, len(c.methods))
|
||||||
for i, val := range c.methods {
|
for i, val := range c.methods {
|
||||||
result[i] = val.Snapshot()
|
result[i] = val.Snapshot()
|
||||||
|
val.ClearInterData()
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -152,6 +152,66 @@ func (n NodeStatistic) AverageCreateSession() time.Duration {
|
||||||
return n.averageTime(methodSessionCreate)
|
return n.averageTime(methodSessionCreate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageGetBalance() time.Duration {
|
||||||
|
return n.interAverageTime(methodBalanceGet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAveragePutContainer() time.Duration {
|
||||||
|
return n.interAverageTime(methodContainerPut)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageGetContainer() time.Duration {
|
||||||
|
return n.interAverageTime(methodContainerGet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageListContainer() time.Duration {
|
||||||
|
return n.interAverageTime(methodContainerList)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageDeleteContainer() time.Duration {
|
||||||
|
return n.interAverageTime(methodContainerDelete)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageGetContainerEACL() time.Duration {
|
||||||
|
return n.interAverageTime(methodContainerEACL)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageSetContainerEACL() time.Duration {
|
||||||
|
return n.interAverageTime(methodContainerSetEACL)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageEndpointInfo() time.Duration {
|
||||||
|
return n.interAverageTime(methodEndpointInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageNetworkInfo() time.Duration {
|
||||||
|
return n.interAverageTime(methodNetworkInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAveragePutObject() time.Duration {
|
||||||
|
return n.interAverageTime(methodObjectPut)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageDeleteObject() time.Duration {
|
||||||
|
return n.interAverageTime(methodObjectDelete)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageGetObject() time.Duration {
|
||||||
|
return n.interAverageTime(methodObjectGet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageHeadObject() time.Duration {
|
||||||
|
return n.interAverageTime(methodObjectHead)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageRangeObject() time.Duration {
|
||||||
|
return n.interAverageTime(methodObjectRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) InterAverageCreateSession() time.Duration {
|
||||||
|
return n.interAverageTime(methodSessionCreate)
|
||||||
|
}
|
||||||
|
|
||||||
func (n NodeStatistic) averageTime(method MethodIndex) time.Duration {
|
func (n NodeStatistic) averageTime(method MethodIndex) time.Duration {
|
||||||
stat := n.methods[method]
|
stat := n.methods[method]
|
||||||
if stat.allRequests == 0 {
|
if stat.allRequests == 0 {
|
||||||
|
@ -160,11 +220,19 @@ func (n NodeStatistic) averageTime(method MethodIndex) time.Duration {
|
||||||
return time.Duration(stat.allTime / stat.allRequests)
|
return time.Duration(stat.allTime / stat.allRequests)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n NodeStatistic) interAverageTime(method MethodIndex) time.Duration {
|
||||||
|
stat := n.methods[method]
|
||||||
|
if stat.interRequests == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return time.Duration(stat.interTime / stat.interRequests)
|
||||||
|
}
|
||||||
|
|
||||||
// MethodStatus provide statistic for specific method.
|
// MethodStatus provide statistic for specific method.
|
||||||
type MethodStatus struct {
|
type MethodStatus struct {
|
||||||
name string
|
name string
|
||||||
mu sync.RWMutex // protect counters
|
mu sync.RWMutex // protect counters
|
||||||
StatusSnapshot
|
snapshot StatusSnapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMethodStatus(name string) *MethodStatus {
|
func NewMethodStatus(name string) *MethodStatus {
|
||||||
|
@ -174,20 +242,32 @@ func NewMethodStatus(name string) *MethodStatus {
|
||||||
func (m *MethodStatus) Snapshot() StatusSnapshot {
|
func (m *MethodStatus) Snapshot() StatusSnapshot {
|
||||||
m.mu.RLock()
|
m.mu.RLock()
|
||||||
defer m.mu.RUnlock()
|
defer m.mu.RUnlock()
|
||||||
return m.StatusSnapshot
|
return m.snapshot
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MethodStatus) ClearInterData() {
|
||||||
|
m.mu.Lock()
|
||||||
|
defer m.mu.Unlock()
|
||||||
|
m.snapshot.interTime = 0
|
||||||
|
m.snapshot.interRequests = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MethodStatus) IncRequests(elapsed time.Duration) {
|
func (m *MethodStatus) IncRequests(elapsed time.Duration) {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
m.allTime += uint64(elapsed)
|
m.snapshot.allTime += uint64(elapsed)
|
||||||
m.allRequests++
|
m.snapshot.interTime += uint64(elapsed)
|
||||||
|
m.snapshot.allRequests++
|
||||||
|
m.snapshot.interRequests++
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatusSnapshot is statistic for specific method.
|
// StatusSnapshot is statistic for specific method.
|
||||||
type StatusSnapshot struct {
|
type StatusSnapshot struct {
|
||||||
allTime uint64
|
allTime uint64
|
||||||
allRequests uint64
|
allRequests uint64
|
||||||
|
|
||||||
|
interTime uint64
|
||||||
|
interRequests uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s StatusSnapshot) AllRequests() uint64 {
|
func (s StatusSnapshot) AllRequests() uint64 {
|
||||||
|
@ -197,3 +277,11 @@ func (s StatusSnapshot) AllRequests() uint64 {
|
||||||
func (s StatusSnapshot) AllTime() uint64 {
|
func (s StatusSnapshot) AllTime() uint64 {
|
||||||
return s.allTime
|
return s.allTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s StatusSnapshot) InterRequests() uint64 {
|
||||||
|
return s.interRequests
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s StatusSnapshot) InterTime() uint64 {
|
||||||
|
return s.interTime
|
||||||
|
}
|
||||||
|
|
|
@ -631,6 +631,7 @@ func (p *Pool) Statistic() Statistic {
|
||||||
|
|
||||||
for i, method := range p.methods {
|
for i, method := range p.methods {
|
||||||
stat.methods[i] = method.Snapshot()
|
stat.methods[i] = method.Snapshot()
|
||||||
|
method.ClearInterData()
|
||||||
}
|
}
|
||||||
|
|
||||||
return stat
|
return stat
|
||||||
|
|
|
@ -42,6 +42,30 @@ func (s *Statistic) AverageRemoveNode() time.Duration {
|
||||||
return s.averageTime(methodRemoveNode)
|
return s.averageTime(methodRemoveNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) InterAverageGetNodes() time.Duration {
|
||||||
|
return s.interAverageTime(methodGetNodes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) InterAverageGetSubTree() time.Duration {
|
||||||
|
return s.interAverageTime(methodGetSubTree)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) InterAverageAddNode() time.Duration {
|
||||||
|
return s.interAverageTime(methodAddNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) InterAverageAddNodeByPath() time.Duration {
|
||||||
|
return s.interAverageTime(methodAddNodeByPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) InterAverageMoveNode() time.Duration {
|
||||||
|
return s.interAverageTime(methodMoveNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) InterAverageRemoveNode() time.Duration {
|
||||||
|
return s.interAverageTime(methodRemoveNode)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Statistic) averageTime(method MethodIndex) time.Duration {
|
func (s *Statistic) averageTime(method MethodIndex) time.Duration {
|
||||||
stat := s.methods[method]
|
stat := s.methods[method]
|
||||||
if stat.AllRequests() == 0 {
|
if stat.AllRequests() == 0 {
|
||||||
|
@ -49,3 +73,11 @@ func (s *Statistic) averageTime(method MethodIndex) time.Duration {
|
||||||
}
|
}
|
||||||
return time.Duration(stat.AllTime() / stat.AllRequests())
|
return time.Duration(stat.AllTime() / stat.AllRequests())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Statistic) interAverageTime(method MethodIndex) time.Duration {
|
||||||
|
stat := s.methods[method]
|
||||||
|
if stat.InterRequests() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return time.Duration(stat.InterTime() / stat.InterRequests())
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue