emit metrics per task id, not event topic

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2025-04-20 15:36:34 +02:00
parent 913cf78690
commit ce5a4d1ef1
@@ -130,7 +130,7 @@ export class GooglePubSubConsumingEventPublisher {
event = this.#messageToEvent(message, task)!;
if (!event) {
this.#metrics.messages.add(1, {
topic: 'unknown',
subscription: task.id,
status: 'ignored',
});
return;
@@ -138,7 +138,7 @@ export class GooglePubSubConsumingEventPublisher {
} catch (error) {
this.#logger.error('Error processing Google Pub/Sub message', error);
this.#metrics.messages.add(1, {
topic: 'unknown',
subscription: task.id,
status: 'failed',
});
// We unconditionally ACK the message in this case, because if it's
@@ -151,14 +151,14 @@ export class GooglePubSubConsumingEventPublisher {
try {
await this.#events.publish(event);
this.#metrics.messages.add(1, {
topic: event.topic,
subscription: task.id,
status: 'success',
});
message.ack();
} catch (error) {
this.#logger.error('Error processing Google Pub/Sub message', error);
this.#metrics.messages.add(1, {
topic: event.topic,
subscription: task.id,
status: 'failed',
});
// We fast-NACK the message in this case because this may be a