You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
584 B
31 lines
584 B
package metrics |
|
|
|
import ( |
|
"time" |
|
|
|
"github.com/owncast/owncast/core" |
|
) |
|
|
|
// How often we poll for updates. |
|
const viewerMetricsPollingInterval = 2 * time.Minute |
|
|
|
func startViewerCollectionMetrics() { |
|
collectViewerCount() |
|
|
|
for range time.Tick(viewerMetricsPollingInterval) { |
|
collectViewerCount() |
|
} |
|
} |
|
|
|
func collectViewerCount() { |
|
if len(Metrics.Viewers) > maxCollectionValues { |
|
Metrics.Viewers = Metrics.Viewers[1:] |
|
} |
|
|
|
count := core.GetStatus().ViewerCount |
|
value := timestampedValue{ |
|
Value: count, |
|
Time: time.Now(), |
|
} |
|
Metrics.Viewers = append(Metrics.Viewers, value) |
|
}
|
|
|