From 35fab191676db498303e29b9162dc30961fbaee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wilczy=C5=84ski?= Date: Fri, 10 Jan 2025 13:53:55 +0100 Subject: [PATCH] [ENG-2343] Stream attempts metric --- monitor/census.go | 10 ++++++++++ server/ai_process.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/monitor/census.go b/monitor/census.go index e5587c0e3..1779ff2d0 100644 --- a/monitor/census.go +++ b/monitor/census.go @@ -991,6 +991,13 @@ func InitCensus(nodeType NodeType, version string) { TagKeys: baseTagsWithOrchInfo, Aggregation: view.Distribution(0, .10, .20, .50, .100, .150, .200, .500, .1000, .5000, 10.000), }, + { + Name: "ai_live_attempt", + Measure: census.mAILiveAttempt, + Description: "AI Live start attempted", + TagKeys: baseTags, + Aggregation: view.Count(), + }, } // Register the views @@ -1991,6 +1998,9 @@ func AIFirstSegmentDelay(delayMs int64, orchInfo *lpnet.OrchestratorInfo) { glog.Errorf("Error recording metrics err=%q", err) } } +func AILiveVideoAttempt() { + stats.Record(census.ctx, census.mAILiveAttempts.M()) +} // Convert wei to gwei func wei2gwei(wei *big.Int) float64 { diff --git a/server/ai_process.go b/server/ai_process.go index 384cadf20..d7197b101 100644 --- a/server/ai_process.go +++ b/server/ai_process.go @@ -1027,6 +1027,9 @@ const initPixelsToPay = 30 * 30 * 3200 * 1800 // 30 seconds, 30fps, 1800p func submitLiveVideoToVideo(ctx context.Context, params aiRequestParams, sess *AISession, req worker.GenLiveVideoToVideoJSONRequestBody) (any, error) { startTime := time.Now() + if monitor.Enabled { + monitor.AILiveVideoAttempt() + } // Live Video should not reuse the existing session balance, because it could lead to not sending the init // payment, which in turns may cause "Insufficient Balance" on the Orchestrator's side. // It works differently than other AI Jobs, because Live Video is accounted by mid on the Orchestrator's side.