Skip to content

Commit

Permalink
feat: Add metrics for colibri-ws closing and receiving an error. (#2128)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev authored Apr 29, 2024
1 parent 462b7f6 commit 748a626
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,18 @@ public void webSocketClosed(ColibriWebSocket ws, int statusCode, String reason)
webSocket = null;
webSocketLastActive = false;
getLogger().info(() -> "Websocket closed, statusCode " + statusCode + " ( " + reason + ").");
// 1000 is normal, 1001 is e.g. a tab closing. 1005 is "No Status Rcvd" and we see the majority of
// sockets close this way.
if (statusCode == 1000 || statusCode == 1001 || statusCode == 1005)
{
VideobridgeMetrics.colibriWebSocketCloseNormal.inc();
}
else
{
VideobridgeMetrics.colibriWebSocketCloseAbnormal.inc();
}
}
}

}

/**
Expand All @@ -365,6 +374,7 @@ public void webSocketClosed(ColibriWebSocket ws, int statusCode, String reason)
public void webSocketError(ColibriWebSocket ws, Throwable cause)
{
getLogger().error("Colibri websocket error: " + cause.getMessage());
VideobridgeMetrics.colibriWebSocketErrors.inc();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ object VideobridgeMetrics {
"Number of messages sent via the data channels of the endpoints of this conference."
)

@JvmField
val colibriWebSocketCloseNormal = metricsContainer.registerCounter(
"colibri_web_socket_close_normal",
"Number of times a colibri web socket was closed normally."
)

@JvmField
val colibriWebSocketCloseAbnormal = metricsContainer.registerCounter(
"colibri_web_socket_close_abnormal",
"Number of times a colibri web socket was closed abnormally."
)

@JvmField
val colibriWebSocketErrors = metricsContainer.registerCounter(
"colibri_web_socket_error",
"Number of times a colibri web socket reported an error."
)

@JvmField
val packetsReceived = metricsContainer.registerCounter(
"packets_received",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ class RelayMessageTransport(
webSocket = null
webSocketLastActive = false
logger.debug { "Web socket closed, statusCode $statusCode ( $reason)." }
// 1000 is normal, 1001 is e.g. a tab closing. 1005 is "No Status Rcvd" and we see the majority of
// sockets close this way.
if (statusCode == 1000 || statusCode == 1001 || statusCode == 1005) {
VideobridgeMetrics.colibriWebSocketCloseNormal.inc()
} else {
VideobridgeMetrics.colibriWebSocketCloseAbnormal.inc()
}
}
}

Expand All @@ -350,8 +357,10 @@ class RelayMessageTransport(
}
}

override fun webSocketError(ws: ColibriWebSocket, cause: Throwable) =
override fun webSocketError(ws: ColibriWebSocket, cause: Throwable) {
logger.error("Colibri websocket error: ${cause.message}")
VideobridgeMetrics.colibriWebSocketErrors.inc()
}

/**
* {@inheritDoc}
Expand Down

0 comments on commit 748a626

Please sign in to comment.