Skip to content

Commit

Permalink
feat: add zone to other metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
bennet-esyoil committed Sep 9, 2024
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
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a37cb70

Please sign in to comment.