From 06eba687c547ba0dee563b902426426349e5ef80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wilczy=C5=84ski?= Date: Mon, 13 Jan 2025 10:08:21 +0100 Subject: [PATCH] [ENG-2343] Stream attempts metric (AI Gateway side) --- server/ai_http.go | 4 ---- server/ai_mediaserver.go | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/ai_http.go b/server/ai_http.go index 6715cc4c6..020c6dc0c 100644 --- a/server/ai_http.go +++ b/server/ai_http.go @@ -95,10 +95,6 @@ func aiHttpHandle[I any](h *lphttp, decoderFunc func(*I, *http.Request) error) h func (h *lphttp) StartLiveVideoToVideo() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if monitor.Enabled { - monitor.AILiveVideoAttempt() - } - remoteAddr := getRemoteAddr(r) ctx := clog.AddVal(r.Context(), clog.ClientIP, remoteAddr) requestID := string(core.RandomManifestID()) diff --git a/server/ai_mediaserver.go b/server/ai_mediaserver.go index 80f92948b..16e45b59d 100644 --- a/server/ai_mediaserver.go +++ b/server/ai_mediaserver.go @@ -439,6 +439,7 @@ func (ls *LivepeerServer) StartLiveVideo() http.Handler { return } } + mediaMTXClient := media.NewMediaMTXClient(remoteHost, ls.mediaMTXApiPassword, sourceID, sourceType) if LiveAIAuthWebhookURL != nil { @@ -488,6 +489,12 @@ func (ls *LivepeerServer) StartLiveVideo() http.Handler { ctx = clog.AddVal(ctx, "stream_id", streamID) clog.Infof(ctx, "Received live video AI request for %s. pipelineParams=%v", streamName, pipelineParams) + // Count `ai_live_attempts` after successful parameters validation + clog.V(common.VERBOSE).Infof(ctx, "AI Live video attempt") + if monitor.Enabled { + monitor.AILiveVideoAttempt() + } + // Kick off the RTMP pull and segmentation as soon as possible ssr := media.NewSwitchableSegmentReader() go func() {