Skip to content

Commit ad98777

Browse files
committed
feat: implement maddy_queue_length metric
The maddy_queue_length was already registered but never used. The gauge is updated when actions on disks are performed: - Incremented when a message is written to disk or when the queue is read from disk. - Decremented when a message is removed from disk. Signed-off-by: spiarh <ludo@spiarh.fr>
1 parent 7cfee98 commit ad98777

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

internal/target/queue/queue.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ import (
8989

9090
// partialError describes state of partially successful message delivery.
9191
type partialError struct {
92-
9392
// Underlying error objects for each recipient.
9493
Errs map[string]error
9594

@@ -129,7 +128,6 @@ type Queue struct {
129128

130129
// Retry delay is calculated using the following formula:
131130
// initialRetryTime * retryTimeScale ^ (TriesCount - 1)
132-
133131
initialRetryTime time.Duration
134132
retryTimeScale float64
135133
maxTries int
@@ -635,6 +633,9 @@ func (q *Queue) removeFromDisk(msgMeta *module.MsgMetadata) {
635633
if err := os.Remove(metaPath); err != nil {
636634
dl.Error("failed to remove meta-data from disk", err)
637635
}
636+
637+
queuedMsgs.WithLabelValues(q.name, q.location).Dec()
638+
638639
dl.Debugf("removed message from disk")
639640
}
640641

@@ -704,6 +705,8 @@ func (q *Queue) readDiskQueue() error {
704705
ID: id,
705706
})
706707
loadedCount++
708+
709+
queuedMsgs.WithLabelValues(q.name, q.location).Inc()
707710
}
708711

709712
if loadedCount != 0 {
@@ -762,6 +765,8 @@ func (q *Queue) storeNewMessage(meta *QueueMetadata, header textproto.Header, bo
762765
return nil, err
763766
}
764767

768+
queuedMsgs.WithLabelValues(q.name, q.location).Inc()
769+
765770
return buffer.FileBuffer{Path: bodyPath, LenHint: body.Len()}, nil
766771
}
767772

0 commit comments

Comments
 (0)