lib/persistentqueue: add vm_persistentqueue_bytes_pending metric (#619)

Metric `vm_persistentqueue_bytes_pending` is a gauge that shows current amount
of bytes in persistentqueue flushed on disk as a difference between write and read
offsets. This metric is very similar to `vmagent_remotewrite_pending_data_bytes`
except of accounting for bytes in-memory.
This commit is contained in:
Roman Khavronenko 2020-07-13 19:54:09 +01:00 committed by GitHub
parent 829ec4f9cf
commit 19dd121968
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,6 +62,8 @@ type Queue struct {
blocksRead *metrics.Counter
bytesRead *metrics.Counter
bytesPending *metrics.Gauge
}
// ResetIfEmpty resets q if it is empty.
@ -166,6 +168,9 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB
q.bytesWritten = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_bytes_written_total{path=%q}`, path))
q.blocksRead = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_blocks_read_total{path=%q}`, path))
q.bytesRead = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_bytes_read_total{path=%q}`, path))
q.bytesPending = metrics.GetOrCreateGauge(fmt.Sprintf(`vm_persistentqueue_bytes_pending{path=%q}`, path), func() float64 {
return float64(q.GetPendingBytes())
})
cleanOnError := func() {
if q.reader != nil {