mirror of https://github.com/calzoneman/sync.git
Fix another bug with prometheus socket.io emtrics
This commit is contained in:
parent
9a1d50dcd3
commit
de5cc3352a
|
@ -275,6 +275,7 @@ const promSocketDisconnect = new Counter({
|
||||||
});
|
});
|
||||||
function emitMetrics(sock) {
|
function emitMetrics(sock) {
|
||||||
try {
|
try {
|
||||||
|
let closed = false;
|
||||||
let transportName = sock.client.conn.transport.name;
|
let transportName = sock.client.conn.transport.name;
|
||||||
promSocketCount.inc({ transport: transportName });
|
promSocketCount.inc({ transport: transportName });
|
||||||
promSocketAccept.inc(1, new Date());
|
promSocketAccept.inc(1, new Date());
|
||||||
|
@ -282,7 +283,7 @@ function emitMetrics(sock) {
|
||||||
sock.client.conn.on('upgrade', newTransport => {
|
sock.client.conn.on('upgrade', newTransport => {
|
||||||
try {
|
try {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (newTransport.name !== transportName) {
|
if (!closed && newTransport.name !== transportName) {
|
||||||
promSocketCount.dec({ transport: transportName });
|
promSocketCount.dec({ transport: transportName });
|
||||||
transportName = newTransport.name;
|
transportName = newTransport.name;
|
||||||
promSocketCount.inc({ transport: transportName });
|
promSocketCount.inc({ transport: transportName });
|
||||||
|
@ -295,6 +296,7 @@ function emitMetrics(sock) {
|
||||||
|
|
||||||
sock.once('disconnect', () => {
|
sock.once('disconnect', () => {
|
||||||
try {
|
try {
|
||||||
|
closed = true;
|
||||||
promSocketCount.dec({ transport: transportName });
|
promSocketCount.dec({ transport: transportName });
|
||||||
promSocketDisconnect.inc(1, new Date());
|
promSocketDisconnect.inc(1, new Date());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue