diff options
Diffstat (limited to 'server/lib/opentelemetry/metric-helpers/playback-metrics.ts')
-rw-r--r-- | server/lib/opentelemetry/metric-helpers/playback-metrics.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/server/lib/opentelemetry/metric-helpers/playback-metrics.ts b/server/lib/opentelemetry/metric-helpers/playback-metrics.ts index 406789618..41a5dd640 100644 --- a/server/lib/opentelemetry/metric-helpers/playback-metrics.ts +++ b/server/lib/opentelemetry/metric-helpers/playback-metrics.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Counter, Meter } from '@opentelemetry/api' | 1 | import { Counter, Histogram, Meter } from '@opentelemetry/api' |
2 | import { MVideoImmutable } from '@server/types/models' | 2 | import { MVideoImmutable } from '@server/types/models' |
3 | import { PlaybackMetricCreate } from '@shared/models' | 3 | import { PlaybackMetricCreate } from '@shared/models' |
4 | 4 | ||
@@ -11,6 +11,8 @@ export class PlaybackMetrics { | |||
11 | 11 | ||
12 | private downloadedBytesHTTPCounter: Counter | 12 | private downloadedBytesHTTPCounter: Counter |
13 | 13 | ||
14 | private peersP2PPeers: Histogram | ||
15 | |||
14 | constructor (private readonly meter: Meter) { | 16 | constructor (private readonly meter: Meter) { |
15 | 17 | ||
16 | } | 18 | } |
@@ -34,6 +36,10 @@ export class PlaybackMetrics { | |||
34 | this.uploadedBytesP2PCounter = this.meter.createCounter('peertube_playback_p2p_uploaded_bytes', { | 36 | this.uploadedBytesP2PCounter = this.meter.createCounter('peertube_playback_p2p_uploaded_bytes', { |
35 | description: 'Uploaded bytes with P2P by PeerTube player.' | 37 | description: 'Uploaded bytes with P2P by PeerTube player.' |
36 | }) | 38 | }) |
39 | |||
40 | this.peersP2PPeers = this.meter.createHistogram('peertube_playback_p2p_peers', { | ||
41 | description: 'Total P2P peers connected to the PeerTube player.' | ||
42 | }) | ||
37 | } | 43 | } |
38 | 44 | ||
39 | observe (video: MVideoImmutable, metrics: PlaybackMetricCreate) { | 45 | observe (video: MVideoImmutable, metrics: PlaybackMetricCreate) { |
@@ -47,6 +53,8 @@ export class PlaybackMetrics { | |||
47 | resolution: metrics.resolution + '', | 53 | resolution: metrics.resolution + '', |
48 | fps: metrics.fps + '', | 54 | fps: metrics.fps + '', |
49 | 55 | ||
56 | p2pEnabled: metrics.p2pEnabled, | ||
57 | |||
50 | videoUUID: video.uuid | 58 | videoUUID: video.uuid |
51 | } | 59 | } |
52 | 60 | ||
@@ -57,5 +65,7 @@ export class PlaybackMetrics { | |||
57 | this.downloadedBytesP2PCounter.add(metrics.downloadedBytesP2P, attributes) | 65 | this.downloadedBytesP2PCounter.add(metrics.downloadedBytesP2P, attributes) |
58 | 66 | ||
59 | this.uploadedBytesP2PCounter.add(metrics.uploadedBytesP2P, attributes) | 67 | this.uploadedBytesP2PCounter.add(metrics.uploadedBytesP2P, attributes) |
68 | |||
69 | if (metrics.totalPeers) this.peersP2PPeers.record(metrics.totalPeers, attributes) | ||
60 | } | 70 | } |
61 | } | 71 | } |