feat: add instance_id to gause calls metric (#87)

Co-authored-by: Quan HL <quanluuhoang8@gmail.com>
This commit is contained in:
Hoan Luu Huu
2023-03-21 18:54:52 +07:00
committed by GitHub
parent 38f2d27246
commit d2f32229a2
2 changed files with 2 additions and 2 deletions

3
app.js
View File

@@ -247,7 +247,8 @@ if (process.env.K8S || process.env.HTTP_PORT) {
if ('test' !== process.env.NODE_ENV) {
/* update call stats periodically */
setInterval(() => {
stats.gauge('sbc.sip.calls.count', activeCallIds.size, ['direction:inbound']);
stats.gauge('sbc.sip.calls.count', activeCallIds.size,
['direction:inbound', `instance_id:${process.env.INSTANCE_ID || 0}`]);
}, 20000);
}

View File

@@ -293,7 +293,6 @@ class CallSession extends Emitter {
} catch (err) {
this.rtpEngineResource.destroy().catch((err) => this.logger.info({err}, 'Error destroying rtpe after failure'));
this.activeCallIds.delete(this.req.get('Call-ID'));
this.stats.gauge('sbc.sip.calls.count', this.activeCallIds.size);
if (err instanceof SipError) {
const tags = ['accepted:no', `sipStatus:${err.status}`, `originator:${this.req.locals.originator}`];
this.stats.increment('sbc.terminations', tags);