add active pipelines.

This commit is contained in:
Miroslav Šedivý 2022-06-19 01:03:16 +02:00
parent 5ab4848580
commit 555fd803bc
4 changed files with 78 additions and 11 deletions

View file

@ -26,6 +26,7 @@ type BroacastManagerCtx struct {
// metrics
pipelinesCounter prometheus.Counter
pipelinesActive prometheus.Gauge
}
func broadcastNew(pipelineStr string) *BroacastManagerCtx {
@ -53,6 +54,18 @@ func broadcastNew(pipelineStr string) *BroacastManagerCtx {
"codec_type": "-",
},
}),
pipelinesActive: promauto.NewGauge(prometheus.GaugeOpts{
Name: "pipelines_active",
Namespace: "neko",
Subsystem: "capture",
Help: "Total number of active pipelines.",
ConstLabels: map[string]string{
"submodule": "broadcast",
"video_id": "main",
"codec_name": "-",
"codec_type": "-",
},
}),
}
}
@ -122,6 +135,7 @@ func (manager *BroacastManagerCtx) createPipeline() error {
manager.pipeline.Play()
manager.pipelinesCounter.Inc()
manager.pipelinesActive.Set(1)
return nil
}
@ -137,4 +151,6 @@ func (manager *BroacastManagerCtx) destroyPipeline() {
manager.pipeline.Destroy()
manager.logger.Info().Msgf("destroying pipeline")
manager.pipeline = nil
manager.pipelinesActive.Set(0)
}