mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-07-23 20:31:51 +00:00
add metrics for auth hook rtt
This commit is contained in:
+14
-1
@@ -1,9 +1,22 @@
|
||||
const debug = require('debug')('jambonz:sbc-inbound');
|
||||
const Emitter = require('events');
|
||||
|
||||
class AuthOutcomeReporter extends Emitter {
|
||||
constructor(stats) {
|
||||
super();
|
||||
this.on('regHookOutcome', ({rtt, status}) => {
|
||||
stats.histogram('app.hook.response_time', rtt, ['hook_type:auth', `status:${status}`]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(srf, logger) {
|
||||
const {lookupSipGatewayBySignalingAddress, lookupAuthHook} = srf.locals.dbHelpers;
|
||||
const authenticator = require('jambonz-http-authenticator')(lookupAuthHook, logger, {blacklistUnknownRealms: true});
|
||||
const {stats} = srf.locals;
|
||||
const authenticator = require('jambonz-http-authenticator')(lookupAuthHook, logger, {
|
||||
blacklistUnknownRealms: true,
|
||||
emitter: new AuthOutcomeReporter(stats)
|
||||
});
|
||||
|
||||
function initLocals(req, res, next) {
|
||||
req.locals = req.locals || {};
|
||||
|
||||
Reference in New Issue
Block a user