mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-10-09 21:14:09 +00:00
more metrics
This commit is contained in:
@@ -14,13 +14,13 @@ const opts = Object.assign({
|
||||
}, {level: process.env.JAMBONES_LOGLEVEL || 'info'});
|
||||
const logger = require('pino')(opts);
|
||||
const StatsCollector = require('jambonz-stats-collector');
|
||||
srf.locals.stats = new StatsCollector(logger);
|
||||
const stats = srf.locals.stats = new StatsCollector(logger);
|
||||
srf.locals.getFeatureServer = require('./lib/fs-tracking')(srf, logger);
|
||||
const {getRtpEngine} = require('jambonz-rtpengine-utils')(process.env.JAMBONES_RTPENGINES.split(','), {
|
||||
emitter: srf.locals.stats
|
||||
});
|
||||
srf.locals.getRtpEngine = getRtpEngine;
|
||||
srf.locals.activeCallIds = new Set();
|
||||
const activeCallIds = srf.locals.activeCallIds = new Set();
|
||||
logger.info('starting..');
|
||||
|
||||
const {
|
||||
@@ -69,4 +69,8 @@ srf.use((req, res, next, err) => {
|
||||
res.send(500);
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
stats.gauge('sbc.sip.calls.count', activeCallIds.size, ['direction:inbound']);
|
||||
}, 3000);
|
||||
|
||||
module.exports = {srf, logger};
|
||||
|
||||
+5
-7
@@ -20,8 +20,6 @@ class CallSession extends Emitter {
|
||||
}
|
||||
|
||||
async connect() {
|
||||
this.activeCallIds.add(this.req.get('Call-ID'));
|
||||
this.stats.gauge('sbc.sip.calls.count', this.activeCallIds.size);
|
||||
const engine = this.getRtpEngine(this.logger);
|
||||
if (!engine) {
|
||||
this.logger.info('No available rtpengines, rejecting call!');
|
||||
@@ -112,10 +110,6 @@ class CallSession extends Emitter {
|
||||
// successfully connected
|
||||
this.logger.info('call connected');
|
||||
debug('call connected');
|
||||
this.emit('connected');
|
||||
const tags = ['accepted:yes', 'sipStatus:200', `originator:${this.req.locals.originator}`];
|
||||
this.stats.increment('sbc.terminations', tags);
|
||||
|
||||
this._setHandlers({uas, uac});
|
||||
return;
|
||||
} catch (err) {
|
||||
@@ -135,6 +129,11 @@ class CallSession extends Emitter {
|
||||
}
|
||||
|
||||
_setHandlers({uas, uac}) {
|
||||
this.emit('connected');
|
||||
const tags = ['accepted:yes', 'sipStatus:200', `originator:${this.req.locals.originator}`];
|
||||
this.stats.increment('sbc.terminations', tags);
|
||||
this.activeCallIds.add(this.req.get('Call-ID'));
|
||||
|
||||
this.uas = uas;
|
||||
this.uac = uac;
|
||||
[uas, uac].forEach((dlg) => {
|
||||
@@ -143,7 +142,6 @@ class CallSession extends Emitter {
|
||||
this.logger.info('call ended');
|
||||
this.rtpEngineResource.destroy();
|
||||
this.activeCallIds.delete(this.req.get('Call-ID'));
|
||||
this.stats.gauge('sbc.sip.calls.count', this.activeCallIds.size);
|
||||
});
|
||||
|
||||
//re-invite
|
||||
|
||||
Reference in New Issue
Block a user