1
0
Fork 0
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:
mcrakhman 2024-08-15 08:28:51 +02:00
parent 2989b11f3c
commit 7e9839336c
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
5 changed files with 41 additions and 5 deletions

View file

@ -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