Track locking metrics

master
Sven Slootweg 2 years ago
parent e2f2fb6cb1
commit f7cd69d7d0

@ -33,7 +33,7 @@ const isTaskObject = require("../validators/is-task-object");
// FIXME: Verify that all internal method calls in the PostgreSQL backend are still valid after moving argument validation/normalization into this module // FIXME: Verify that all internal method calls in the PostgreSQL backend are still valid after moving argument validation/normalization into this module
module.exports = function (state) { module.exports = function (state) {
let { tasks } = state; let { tasks, metrics } = state;
const backendModules = { const backendModules = {
"postgresql": require("./postgresql")(state), "postgresql": require("./postgresql")(state),
@ -370,7 +370,15 @@ module.exports = function (state) {
}] }]
}); });
return Promise.try(() => {
return backend.lock(tx, options); return backend.lock(tx, options);
}).tap((succeeded) => {
if (succeeded) {
metrics.successfulLocks.labels({ task: task.name }).inc(1);
} else {
metrics.failedLocks.labels({ task: task.name }).inc(1);
}
});
}, },
unlock: function (_tx, _options) { unlock: function (_tx, _options) {

@ -27,6 +27,18 @@ module.exports = function createPrometheus() {
help: "Amount of items that have failed during processing", help: "Amount of items that have failed during processing",
labelNames: [ "task" ] labelNames: [ "task" ]
}), }),
successfulLocks: new prometheusClient.Counter({
registers: [ prometheusRegistry ],
name: "srap_successful_locks_total",
help: "Amount of queue item lock attempts that were successful",
labelNames: [ "task" ]
}),
failedLocks: new prometheusClient.Counter({
registers: [ prometheusRegistry ],
name: "srap_failed_locks_total",
help: "Amount of queue item lock attempts that failed",
labelNames: [ "task" ]
}),
taskFetchTime: new prometheusClient.Gauge({ taskFetchTime: new prometheusClient.Gauge({
registers: [ prometheusRegistry ], registers: [ prometheusRegistry ],
name: "srap_task_fetch_seconds", name: "srap_task_fetch_seconds",

Loading…
Cancel
Save