Skip to content

Commit 3ee1eae

Browse files
authored
Merge pull request #780 from spiarh/implement_queue_length_metric
Implement maddy_queue_length metric
2 parents a89b044 + ad98777 commit 3ee1eae

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

internal/endpoint/smtp/metrics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var (
2626
Namespace: "maddy",
2727
Subsystem: "smtp",
2828
Name: "started_transactions",
29-
Help: "Amount of SMTP trasanactions started",
29+
Help: "Amount of SMTP transactions started",
3030
},
3131
[]string{"module"},
3232
)
@@ -35,7 +35,7 @@ var (
3535
Namespace: "maddy",
3636
Subsystem: "smtp",
3737
Name: "smtp_completed_transactions",
38-
Help: "Amount of SMTP trasanactions successfully completed",
38+
Help: "Amount of SMTP transactions successfully completed",
3939
},
4040
[]string{"module"},
4141
)
@@ -44,7 +44,7 @@ var (
4444
Namespace: "maddy",
4545
Subsystem: "smtp",
4646
Name: "aborted_transactions",
47-
Help: "Amount of SMTP trasanactions aborted",
47+
Help: "Amount of SMTP transactions aborted",
4848
},
4949
[]string{"module"},
5050
)

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)