From 5ab4848580b73ae25ab6a909db91150a4296105c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 19 Jun 2022 00:51:17 +0200 Subject: [PATCH] join pipelines_total. --- internal/capture/broadcast.go | 8 +++++++- internal/capture/screencast.go | 12 +++++++++--- internal/capture/streamsink.go | 17 ++++++++++------- internal/capture/streamsrc.go | 31 +++++++++++++++++++++---------- 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/internal/capture/broadcast.go b/internal/capture/broadcast.go index bb6d27be..4e860f03 100644 --- a/internal/capture/broadcast.go +++ b/internal/capture/broadcast.go @@ -44,8 +44,14 @@ func broadcastNew(pipelineStr string) *BroacastManagerCtx { pipelinesCounter: promauto.NewCounter(prometheus.CounterOpts{ Name: "pipelines_total", Namespace: "neko", - Subsystem: "capture_broadcast", + Subsystem: "capture", Help: "Total number of created pipelines.", + ConstLabels: map[string]string{ + "submodule": "broadcast", + "video_id": "main", + "codec_name": "-", + "codec_type": "-", + }, }), } } diff --git a/internal/capture/screencast.go b/internal/capture/screencast.go index d6b815a4..a8314d31 100644 --- a/internal/capture/screencast.go +++ b/internal/capture/screencast.go @@ -55,16 +55,22 @@ func screencastNew(enabled bool, pipelineStr string) *ScreencastManagerCtx { // metrics imagesCounter: promauto.NewCounter(prometheus.CounterOpts{ - Name: "images_total", + Name: "screencast_images_total", Namespace: "neko", - Subsystem: "capture_screencast", + Subsystem: "capture", Help: "Total number of created images.", }), pipelinesCounter: promauto.NewCounter(prometheus.CounterOpts{ Name: "pipelines_total", Namespace: "neko", - Subsystem: "capture_screencast", + Subsystem: "capture", Help: "Total number of created pipelines.", + ConstLabels: map[string]string{ + "submodule": "screencast", + "video_id": "main", + "codec_name": "-", + "codec_type": "-", + }, }), } diff --git a/internal/capture/streamsink.go b/internal/capture/streamsink.go index 8b1faad4..8de12b9b 100644 --- a/internal/capture/streamsink.go +++ b/internal/capture/streamsink.go @@ -50,23 +50,26 @@ func streamSinkNew(codec codec.RTPCodec, pipelineStr func() string, video_id str // metrics currentListeners: promauto.NewGauge(prometheus.GaugeOpts{ - Name: "listeners", + Name: "streamsink_listeners", Namespace: "neko", - Subsystem: "capture_streamsink", + Subsystem: "capture", Help: "Current number of listeners for a pipeline.", ConstLabels: map[string]string{ - "video_id": video_id, - "codec": codec.Name, + "video_id": video_id, + "codec_name": codec.Name, + "codec_type": codec.Type.String(), }, }), pipelinesCounter: promauto.NewCounter(prometheus.CounterOpts{ Name: "pipelines_total", Namespace: "neko", - Subsystem: "capture_streamsink", + Subsystem: "capture", Help: "Total number of created pipelines.", ConstLabels: map[string]string{ - "video_id": video_id, - "codec": codec.Name, + "submodule": "streamsink", + "video_id": video_id, + "codec_name": codec.Name, + "codec_type": codec.Type.String(), }, }), } diff --git a/internal/capture/streamsrc.go b/internal/capture/streamsrc.go index c6583670..fbf4303a 100644 --- a/internal/capture/streamsrc.go +++ b/internal/capture/streamsrc.go @@ -37,25 +37,36 @@ func streamSrcNew(enabled bool, codecPipeline map[string]string, video_id string pushedData := map[string]prometheus.Summary{} pipelinesCounter := map[string]prometheus.Counter{} - for codec := range codecPipeline { - pushedData[codec] = promauto.NewSummary(prometheus.SummaryOpts{ - Name: "data_bytes", + for codecName, pipeline := range codecPipeline { + codec, ok := codec.ParseStr(codecName) + if !ok { + logger.Fatal(). + Str("codec", codecName). + Str("pipeline", pipeline). + Msg("unknown codec name") + } + + pushedData[codecName] = promauto.NewSummary(prometheus.SummaryOpts{ + Name: "streamsrc_data_bytes", Namespace: "neko", - Subsystem: "capture_streamsrc", + Subsystem: "capture", Help: "Data pushed to a pipeline (in bytes).", ConstLabels: map[string]string{ - "video_id": video_id, - "codec": codec, + "video_id": video_id, + "codec_name": codec.Name, + "codec_type": codec.Type.String(), }, }) - pipelinesCounter[codec] = promauto.NewCounter(prometheus.CounterOpts{ + pipelinesCounter[codecName] = promauto.NewCounter(prometheus.CounterOpts{ Name: "pipelines_total", Namespace: "neko", - Subsystem: "capture_streamsrc", + Subsystem: "capture", Help: "Total number of created pipelines.", ConstLabels: map[string]string{ - "video_id": video_id, - "codec": codec, + "submodule": "streamsrc", + "video_id": video_id, + "codec_name": codec.Name, + "codec_type": codec.Type.String(), }, }) }