Skip to content

Implement maddy_queue_length metric #780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/endpoint/smtp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
)
Expand All @@ -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"},
)
Expand All @@ -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"},
)
Expand Down
9 changes: 7 additions & 2 deletions internal/target/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -704,6 +705,8 @@ func (q *Queue) readDiskQueue() error {
ID: id,
})
loadedCount++

queuedMsgs.WithLabelValues(q.name, q.location).Inc()
}

if loadedCount != 0 {
Expand Down Expand Up @@ -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
}

Expand Down