Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add zone to other metrics
Browse files Browse the repository at this point in the history
bennet-esyoil committed Sep 9, 2024

Unverified

This user has not yet uploaded their public signing key.
1 parent 2c4f865 commit a37cb70
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/queue-server.js
Original file line number Diff line number Diff line change
@@ -18,15 +18,17 @@ const deliveryStatusCounter = new promClient.Counter({
const messagePushCounter = new promClient.Counter({
name: 'zonemta_message_push',
help: 'Messages pushed to queue',
labelNames: ['result']
labelNames: ['result', 'zone']
});
const bounceCounter = new promClient.Counter({
name: 'zonemta_bounce_generation',
help: 'Bounce generation'
help: 'Bounce generation',
labelNames: ['zone']
});
const dropCounter = new promClient.Counter({
name: 'zonemta_message_drop',
help: 'Messages dropped'
help: 'Messages dropped',
labelNames: ['zone']
});

const promMetrics = {
@@ -213,7 +215,9 @@ class QueueServer {

case 'BOUNCE':
{
bounceCounter.inc();
bounceCounter.inc({
zone: client.zone.name
});
const bounce = data;
bounce.headers = new Headers(bounce.headers || []);
plugins.handler.runHooks(
@@ -230,7 +234,9 @@ class QueueServer {
break;

case 'REMOVE':
dropCounter.inc();
dropCounter.inc({
zone: client.zone.name
});
this.queue.removeMessage(data.id, err => {
if (!client) {
// client already errored or closed
@@ -290,7 +296,8 @@ class QueueServer {
case 'PUSH':
this.queue.push(data.id, data.envelope, err => {
messagePushCounter.inc({
result: err ? 'fail' : 'success'
result: err ? 'fail' : 'success',
zone: client.zone.name
});
if (!client) {
// client already errored or closed

0 comments on commit a37cb70

Please sign in to comment.