Skip to content

Commit

Permalink
Prevent negative network tx/rx data for process (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomac authored Sep 2, 2024
1 parent b71dc56 commit 9a20dda
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/internal/infraolly/process/harvest.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,15 @@ func (ps *Harvester) populateNetworkInfo(status *Status, source *linuxProcess) {
return
}
rx, tx := parseProcNetDev(content)
status.NetRcvBytesDelta = rx - source.previousNetRx
status.NetTxBytesDelta = tx - source.previousNetTx
// removing a row in the /proc/<pid>/net/dev table could cause a negative delta
// and crashing the counters in the instrumentation libraries
if rx <= source.previousNetRx || tx <= source.previousNetTx {
status.NetRcvBytesDelta = 0
status.NetTxBytesDelta = 0
} else {
status.NetRcvBytesDelta = rx - source.previousNetRx
status.NetTxBytesDelta = tx - source.previousNetTx
}
source.previousNetRx = rx
source.previousNetTx = tx
}

0 comments on commit 9a20dda

Please sign in to comment.