From 7cfee986906dac85144b7312913087ab4706ff72 Mon Sep 17 00:00:00 2001 From: spiarh Date: Tue, 15 Apr 2025 15:25:03 +0200 Subject: [PATCH 1/2] fix: replace typo trasanactions with transactions Signed-off-by: spiarh --- internal/endpoint/smtp/metrics.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/endpoint/smtp/metrics.go b/internal/endpoint/smtp/metrics.go index 509241bc..8c9a7188 100644 --- a/internal/endpoint/smtp/metrics.go +++ b/internal/endpoint/smtp/metrics.go @@ -26,7 +26,7 @@ var ( Namespace: "maddy", Subsystem: "smtp", Name: "started_transactions", - Help: "Amount of SMTP trasanactions started", + Help: "Amount of SMTP transactions started", }, []string{"module"}, ) @@ -35,7 +35,7 @@ var ( Namespace: "maddy", Subsystem: "smtp", Name: "smtp_completed_transactions", - Help: "Amount of SMTP trasanactions successfully completed", + Help: "Amount of SMTP transactions successfully completed", }, []string{"module"}, ) @@ -44,7 +44,7 @@ var ( Namespace: "maddy", Subsystem: "smtp", Name: "aborted_transactions", - Help: "Amount of SMTP trasanactions aborted", + Help: "Amount of SMTP transactions aborted", }, []string{"module"}, ) From ad98777e45587062bf7f1e3fdb4e1546010f2b3c Mon Sep 17 00:00:00 2001 From: spiarh Date: Tue, 15 Apr 2025 15:26:07 +0200 Subject: [PATCH 2/2] 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 --- internal/target/queue/queue.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/target/queue/queue.go b/internal/target/queue/queue.go index 264a70fb..4bea9053 100644 --- a/internal/target/queue/queue.go +++ b/internal/target/queue/queue.go @@ -89,7 +89,6 @@ import ( // partialError describes state of partially successful message delivery. type partialError struct { - // Underlying error objects for each recipient. Errs map[string]error @@ -129,7 +128,6 @@ type Queue struct { // Retry delay is calculated using the following formula: // initialRetryTime * retryTimeScale ^ (TriesCount - 1) - initialRetryTime time.Duration retryTimeScale float64 maxTries int @@ -635,6 +633,9 @@ func (q *Queue) removeFromDisk(msgMeta *module.MsgMetadata) { if err := os.Remove(metaPath); err != nil { dl.Error("failed to remove meta-data from disk", err) } + + queuedMsgs.WithLabelValues(q.name, q.location).Dec() + dl.Debugf("removed message from disk") } @@ -704,6 +705,8 @@ func (q *Queue) readDiskQueue() error { ID: id, }) loadedCount++ + + queuedMsgs.WithLabelValues(q.name, q.location).Inc() } if loadedCount != 0 { @@ -762,6 +765,8 @@ func (q *Queue) storeNewMessage(meta *QueueMetadata, header textproto.Header, bo return nil, err } + queuedMsgs.WithLabelValues(q.name, q.location).Inc() + return buffer.FileBuffer{Path: bodyPath, LenHint: body.Len()}, nil }