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

@ -34,6 +34,7 @@ type StreamSinkManagerCtx struct {
// metrics
currentListeners prometheus.Gauge
pipelinesCounter prometheus.Counter
pipelinesActive prometheus.Gauge
}
func streamSinkNew(codec codec.RTPCodec, pipelineStr func() string, video_id string) *StreamSinkManagerCtx {
@ -72,6 +73,18 @@ func streamSinkNew(codec codec.RTPCodec, pipelineStr func() string, video_id str
"codec_type": codec.Type.String(),
},
}),
pipelinesActive: promauto.NewGauge(prometheus.GaugeOpts{
Name: "pipelines_active",
Namespace: "neko",
Subsystem: "capture",
Help: "Total number of active pipelines.",
ConstLabels: map[string]string{
"submodule": "streamsink",
"video_id": video_id,
"codec_name": codec.Name,
"codec_type": codec.Type.String(),
},
}),
}
return manager
@ -275,6 +288,8 @@ func (manager *StreamSinkManagerCtx) createPipeline() error {
}()
manager.pipelinesCounter.Inc()
manager.pipelinesActive.Set(1)
return nil
}
@ -289,4 +304,6 @@ func (manager *StreamSinkManagerCtx) destroyPipeline() {
manager.pipeline.Destroy()
manager.logger.Info().Msgf("destroying pipeline")
manager.pipeline = nil
manager.pipelinesActive.Set(0)
}