Skip to content

Commit

Permalink
include code label for success counter and use finally to unlock mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaamani committed Jul 25, 2023
1 parent 132bbb6 commit a58a175
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const metrics = {
register_success: new prom.Counter({
name: 'register_success',
help: 'Total successful registrations.',
labelNames: ['code'],
}),
register_failure_user: new prom.Counter({
name: 'register_failure_user',
Expand Down Expand Up @@ -162,16 +163,16 @@ app.post('/register', async (req, res) => {
callback
)
} catch (err) {
processingRequest.unlock()
log(err)
res.status(500).end()
metrics.register_failure_server.inc(
{ code: 500, reason: 'internal_error' },
1
)
} finally {
processingRequest.unlock()
stopTimer()
}
processingRequest.unlock()
stopTimer()
})
})

Expand Down

0 comments on commit a58a175

Please sign in to comment.