mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
Add streampool msg size
This commit is contained in:
parent
2989b11f3c
commit
7e9839336c
5 changed files with 41 additions and 5 deletions
|
@ -10,6 +10,10 @@ type SyncMetric interface {
|
|||
SyncMetricState() SyncMetricState
|
||||
}
|
||||
|
||||
type StreamPoolMetric interface {
|
||||
OutgoingMsg() (count uint32, size uint64)
|
||||
}
|
||||
|
||||
type SyncMetricState struct {
|
||||
IncomingMsgCount uint32
|
||||
IncomingMsgSize uint64
|
||||
|
@ -28,13 +32,11 @@ type SyncMetricState struct {
|
|||
|
||||
func (st *SyncMetricState) Append(other SyncMetricState) {
|
||||
st.IncomingMsgSize += other.IncomingMsgSize
|
||||
st.OutgoingMsgSize += other.OutgoingMsgSize
|
||||
st.IncomingReqSize += other.IncomingReqSize
|
||||
st.OutgoingReqSize += other.OutgoingReqSize
|
||||
st.ReceivedRespSize += other.ReceivedRespSize
|
||||
st.SentRespSize += other.SentRespSize
|
||||
st.IncomingMsgCount += other.IncomingMsgCount
|
||||
st.OutgoingMsgCount += other.OutgoingMsgCount
|
||||
st.IncomingReqCount += other.IncomingReqCount
|
||||
st.OutgoingReqCount += other.OutgoingReqCount
|
||||
st.ReceivedRespCount += other.ReceivedRespCount
|
||||
|
@ -58,6 +60,9 @@ func (m *metric) getLastCached() SyncMetricState {
|
|||
for _, mtr := range allMetrics {
|
||||
lastCached.Append(mtr.SyncMetricState())
|
||||
}
|
||||
if m.streamPoolMetric != nil {
|
||||
lastCached.OutgoingMsgCount, lastCached.OutgoingMsgSize = m.streamPoolMetric.OutgoingMsg()
|
||||
}
|
||||
m.mx.Lock()
|
||||
defer m.mx.Unlock()
|
||||
m.lastCachedState = lastCached
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue