Init commit

This commit is contained in:
ShreejitPanchal
2026-05-19 19:56:02 +08:00
commit 6601501eff
4047 changed files with 2185372 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { Meter } from '@opentelemetry/api'
import { VideoScope, ViewerScope } from '@server/lib/views/shared/index.js'
import { VideoViewsManager } from '@server/lib/views/video-views-manager.js'
export class ViewersObserversBuilder {
constructor (private readonly meter: Meter) {
}
buildObservers () {
this.meter.createObservableGauge('peertube_viewers_total', {
description: 'Total viewers on the instance'
}).addCallback(observableResult => {
for (const viewerScope of [ 'local', 'remote' ] as ViewerScope[]) {
for (const videoScope of [ 'local', 'remote' ] as VideoScope[]) {
const result = VideoViewsManager.Instance.getTotalViewers({ viewerScope, videoScope })
observableResult.observe(result, { viewerOrigin: viewerScope, videoOrigin: videoScope })
}
}
})
}
}