From 305facdfab1d5029366d2262ac390b9c71752e4b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 20 Jul 2023 12:06:39 +0200 Subject: Add peers number and p2p enabled label to metrics --- client/src/assets/player/shared/metrics/metrics-plugin.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'client') diff --git a/client/src/assets/player/shared/metrics/metrics-plugin.ts b/client/src/assets/player/shared/metrics/metrics-plugin.ts index 6ca368f87..20d37d636 100644 --- a/client/src/assets/player/shared/metrics/metrics-plugin.ts +++ b/client/src/assets/player/shared/metrics/metrics-plugin.ts @@ -18,6 +18,9 @@ class MetricsPlugin extends Plugin { private resolutionChanges = 0 private errors = 0 + private p2pEnabled: boolean + private totalPeers = 0 + private lastPlayerNetworkInfo: PlayerNetworkInfo private metricsInterval: any @@ -113,6 +116,9 @@ class MetricsPlugin extends Plugin { uploadedBytesP2P: this.uploadedBytesP2P, + totalPeers: this.totalPeers, + p2pEnabled: this.p2pEnabled, + videoId: this.options_.videoUUID() } @@ -139,12 +145,18 @@ class MetricsPlugin extends Plugin { this.uploadedBytesP2P += Math.round(data.p2p.uploaded - (this.lastPlayerNetworkInfo?.p2p.uploaded || 0)) + this.totalPeers = data.p2p.numPeers + this.p2pEnabled = true + this.lastPlayerNetworkInfo = data }) this.player.on('http-info', (_event, data: PlayerNetworkInfo) => { this.downloadedBytesHTTP += Math.round(data.http.downloaded - (this.lastPlayerNetworkInfo?.http.downloaded || 0)) + this.totalPeers = 0 + this.p2pEnabled = false + this.lastPlayerNetworkInfo = data }) } -- cgit v1.2.3