diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-20 12:06:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-20 12:06:39 +0200 |
commit | 305facdfab1d5029366d2262ac390b9c71752e4b (patch) | |
tree | 799f7e5686d0ac0b9ff63a06e686d6f1093168bc /client | |
parent | 4e5da193d0ef69f7fc0ee1e7eb14f03de4d7a938 (diff) | |
download | PeerTube-305facdfab1d5029366d2262ac390b9c71752e4b.tar.gz PeerTube-305facdfab1d5029366d2262ac390b9c71752e4b.tar.zst PeerTube-305facdfab1d5029366d2262ac390b9c71752e4b.zip |
Add peers number and p2p enabled label to metrics
Diffstat (limited to 'client')
-rw-r--r-- | client/src/assets/player/shared/metrics/metrics-plugin.ts | 12 |
1 files changed, 12 insertions, 0 deletions
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 { | |||
18 | private resolutionChanges = 0 | 18 | private resolutionChanges = 0 |
19 | private errors = 0 | 19 | private errors = 0 |
20 | 20 | ||
21 | private p2pEnabled: boolean | ||
22 | private totalPeers = 0 | ||
23 | |||
21 | private lastPlayerNetworkInfo: PlayerNetworkInfo | 24 | private lastPlayerNetworkInfo: PlayerNetworkInfo |
22 | 25 | ||
23 | private metricsInterval: any | 26 | private metricsInterval: any |
@@ -113,6 +116,9 @@ class MetricsPlugin extends Plugin { | |||
113 | 116 | ||
114 | uploadedBytesP2P: this.uploadedBytesP2P, | 117 | uploadedBytesP2P: this.uploadedBytesP2P, |
115 | 118 | ||
119 | totalPeers: this.totalPeers, | ||
120 | p2pEnabled: this.p2pEnabled, | ||
121 | |||
116 | videoId: this.options_.videoUUID() | 122 | videoId: this.options_.videoUUID() |
117 | } | 123 | } |
118 | 124 | ||
@@ -139,12 +145,18 @@ class MetricsPlugin extends Plugin { | |||
139 | 145 | ||
140 | this.uploadedBytesP2P += Math.round(data.p2p.uploaded - (this.lastPlayerNetworkInfo?.p2p.uploaded || 0)) | 146 | this.uploadedBytesP2P += Math.round(data.p2p.uploaded - (this.lastPlayerNetworkInfo?.p2p.uploaded || 0)) |
141 | 147 | ||
148 | this.totalPeers = data.p2p.numPeers | ||
149 | this.p2pEnabled = true | ||
150 | |||
142 | this.lastPlayerNetworkInfo = data | 151 | this.lastPlayerNetworkInfo = data |
143 | }) | 152 | }) |
144 | 153 | ||
145 | this.player.on('http-info', (_event, data: PlayerNetworkInfo) => { | 154 | this.player.on('http-info', (_event, data: PlayerNetworkInfo) => { |
146 | this.downloadedBytesHTTP += Math.round(data.http.downloaded - (this.lastPlayerNetworkInfo?.http.downloaded || 0)) | 155 | this.downloadedBytesHTTP += Math.round(data.http.downloaded - (this.lastPlayerNetworkInfo?.http.downloaded || 0)) |
147 | 156 | ||
157 | this.totalPeers = 0 | ||
158 | this.p2pEnabled = false | ||
159 | |||
148 | this.lastPlayerNetworkInfo = data | 160 | this.lastPlayerNetworkInfo = data |
149 | }) | 161 | }) |
150 | } | 162 | } |