From c96727403a620d39a9bb85b3aba365d6ed7a6006 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Fri, 9 Dec 2016 16:21:58 -0600 Subject: [PATCH] stats: Adds the number of messages sent and received over data channels to the statistics. --- doc/statistics.md | 2 ++ .../org/jitsi/videobridge/Conference.java | 2 +- .../java/org/jitsi/videobridge/Endpoint.java | 5 ++++ .../org/jitsi/videobridge/Videobridge.java | 12 +++++++++ .../stats/VideobridgeStatistics.java | 25 +++++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/doc/statistics.md b/doc/statistics.md index 2fb4cf6102..3d9bad73a0 100644 --- a/doc/statistics.md +++ b/doc/statistics.md @@ -11,6 +11,7 @@ Introduction * The distribution of the sizes of the conferences currently in progress. * Aggregates of RTT and jitter across all users. * The total number of created, completed, failed and partially failed conferences. + * The total number of messages sent and received through data channels. * The total duration of all completed conferences. * The number of ICE sessions established over UDP or TCP. @@ -46,6 +47,7 @@ generated (in UTC). * **total_no_payload_channels** - The total number of channels with no payload activity. * **total_no_transport_channels** - The total number of channels with no transport activity. * **total_channels** - The total number of channels created on the bridge. + * **total_data_channel_messages_received / total_data_channel_messages_sent** - The total number messages received and sent through data channels. If Jitsi Videobridge is using XMPP it sends the statistics reports by COLIBRI protocol or by PubSub (XEP-0060). diff --git a/src/main/java/org/jitsi/videobridge/Conference.java b/src/main/java/org/jitsi/videobridge/Conference.java index 671f1fed9a..b98f215381 100644 --- a/src/main/java/org/jitsi/videobridge/Conference.java +++ b/src/main/java/org/jitsi/videobridge/Conference.java @@ -177,7 +177,7 @@ public class Conference /** * Holds conference statistics. */ - private Statistics statistics = new Statistics(); + private final Statistics statistics = new Statistics(); /** * The WebRtcpDataStreamListener which listens to the diff --git a/src/main/java/org/jitsi/videobridge/Endpoint.java b/src/main/java/org/jitsi/videobridge/Endpoint.java index 6aef559fa3..f23b6e3b0f 100644 --- a/src/main/java/org/jitsi/videobridge/Endpoint.java +++ b/src/main/java/org/jitsi/videobridge/Endpoint.java @@ -483,6 +483,9 @@ private void onJSONData( JSONObject jsonObject, Object colibriClass) { + getConference().getVideobridge().getStatistics(). + totalDataChannelMessagesReceived.incrementAndGet(); + if (COLIBRI_CLASS_SELECTED_ENDPOINT_CHANGED.equals(colibriClass)) onSelectedEndpointChangedEvent(src, jsonObject); else if (COLIBRI_CLASS_PINNED_ENDPOINT_CHANGED.equals(colibriClass)) @@ -939,6 +942,8 @@ else if(sctpConnection.isReady()) else { dataStream.sendString(msg); + getConference().getVideobridge().getStatistics() + .totalDataChannelMessagesSent.incrementAndGet(); } } catch (IOException e) diff --git a/src/main/java/org/jitsi/videobridge/Videobridge.java b/src/main/java/org/jitsi/videobridge/Videobridge.java index 74606a4052..33b9e5946c 100644 --- a/src/main/java/org/jitsi/videobridge/Videobridge.java +++ b/src/main/java/org/jitsi/videobridge/Videobridge.java @@ -1725,5 +1725,17 @@ public static class Statistics * successfully connected over TCP. */ public AtomicInteger totalTcpTransportManagers = new AtomicInteger(); + + /** + * The total number of messages received from the data channels of + * the {@link Endpoint}s of this conference. + */ + public AtomicLong totalDataChannelMessagesReceived = new AtomicLong(); + + /** + * The total number of messages sent via the data channels of the + * {@link Endpoint}s of this conference. + */ + public AtomicLong totalDataChannelMessagesSent = new AtomicLong(); } } diff --git a/src/main/java/org/jitsi/videobridge/stats/VideobridgeStatistics.java b/src/main/java/org/jitsi/videobridge/stats/VideobridgeStatistics.java index 4edafc4790..1545b17dd7 100644 --- a/src/main/java/org/jitsi/videobridge/stats/VideobridgeStatistics.java +++ b/src/main/java/org/jitsi/videobridge/stats/VideobridgeStatistics.java @@ -214,6 +214,20 @@ public class VideobridgeStatistics */ private static final String TOTAL_TCP_CONNECTIONS = "total_tcp_connections"; + /** + * The name of the stat indicating the total number of messages received + * from data channels. + */ + private static final String TOTAL_DATA_CHANNEL_MESSAGES_RECEIVED + = "total_data_channel_messages_received"; + + /** + * The name of the stat indicating the total number of messages sent over + * data channels. + */ + private static final String TOTAL_DATA_CHANNEL_MESSAGES_SENT + = "total_data_channel_messages_sent"; + /** * The name of used memory statistic. Its runtime type is {@code Integer}. */ @@ -364,6 +378,8 @@ protected void generate0() totalChannels = 0; long totalConferenceSeconds = 0; int totalUdpConnections = 0, totalTcpConnections = 0; + long totalDataChannelMessagesReceived = 0; + long totalDataChannelMessagesSent = 0; BundleContext bundleContext = StatsManagerBundleActivator.getBundleContext(); @@ -383,6 +399,11 @@ protected void generate0() totalChannels += jvbStats.totalChannels.get(); totalUdpConnections += jvbStats.totalUdpTransportManagers.get(); totalTcpConnections += jvbStats.totalTcpTransportManagers.get(); + totalDataChannelMessagesReceived + += jvbStats.totalDataChannelMessagesReceived.get(); + totalDataChannelMessagesSent + += jvbStats.totalDataChannelMessagesSent.get(); + for (Conference conference : videobridge.getConferences()) { @@ -588,6 +609,10 @@ else if (MediaType.VIDEO.equals(mediaType)) unlockedSetStat(TOTAL_MEMORY, Math.max(totalMemory, 0)); unlockedSetStat(USED_MEMORY, Math.max(usedMemory, 0)); unlockedSetStat(SHUTDOWN_IN_PROGRESS, shutdownInProgress); + unlockedSetStat(TOTAL_DATA_CHANNEL_MESSAGES_RECEIVED, + totalDataChannelMessagesReceived); + unlockedSetStat(TOTAL_DATA_CHANNEL_MESSAGES_SENT, + totalDataChannelMessagesSent); unlockedSetStat(TIMESTAMP, timestamp); }