Fix traffic metrics (#879)

This commit is contained in:
Tanguy 2023-04-03 14:37:23 +02:00 committed by GitHub
parent 4aa615c44c
commit 95e98e8c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -103,11 +103,11 @@ method readOnce*(s: ChronosStream, pbytes: pointer, nbytes: int): Future[int] {.
withExceptions: withExceptions:
result = await s.client.readOnce(pbytes, nbytes) result = await s.client.readOnce(pbytes, nbytes)
s.activity = true # reset activity flag s.activity = true # reset activity flag
libp2p_network_bytes.inc(nbytes.int64, labelValues = ["in"]) libp2p_network_bytes.inc(result.int64, labelValues = ["in"])
when defined(libp2p_agents_metrics): when defined(libp2p_agents_metrics):
s.trackPeerIdentity() s.trackPeerIdentity()
if s.tracked: if s.tracked:
libp2p_peers_traffic_read.inc(nbytes.int64, labelValues = [s.shortAgent]) libp2p_peers_traffic_read.inc(result.int64, labelValues = [s.shortAgent])
proc completeWrite( proc completeWrite(
s: ChronosStream, fut: Future[int], msgLen: int): Future[void] {.async.} = s: ChronosStream, fut: Future[int], msgLen: int): Future[void] {.async.} =