From 7bfdd45333887c2acecf3793c41042826605f011 Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Wed, 17 Jul 2024 21:17:50 +0200 Subject: [PATCH] refactor: improve orchestrator metrics tags This commit ensures that the right tags are attached to the Orchestrator AI metrics. --- monitor/census.go | 10 ++++++---- server/ai_http.go | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/monitor/census.go b/monitor/census.go index 4a432a8753..d6140ac82c 100644 --- a/monitor/census.go +++ b/monitor/census.go @@ -397,10 +397,12 @@ func InitCensus(nodeType NodeType, version string) { // Add node type specific tags. baseTagsWithNodeInfo := baseTags + aiRequestLatencyScoreTags := baseTags if nodeType == Orchestrator { - baseTagsWithNodeInfo = baseTagsWithOrchInfo - } else { baseTagsWithNodeInfo = baseTagsWithGatewayInfo + } else { + baseTagsWithNodeInfo = baseTagsWithOrchInfo + aiRequestLatencyScoreTags = baseTagsWithOrchInfo } views := []*view.View{ @@ -899,14 +901,14 @@ func InitCensus(nodeType NodeType, version string) { Name: "ai_request_latency_score", Measure: census.mAIRequestLatencyScore, Description: "AI request latency score", - TagKeys: append([]tag.Key{census.kPipeline, census.kModelName}, baseTagsWithNodeInfo...), + TagKeys: append([]tag.Key{census.kPipeline, census.kModelName}, aiRequestLatencyScoreTags...), Aggregation: view.LastValue(), }, { Name: "ai_request_price", Measure: census.mAIRequestPrice, Description: "AI request price per unit", - TagKeys: append([]tag.Key{census.kPipeline, census.kModelName}, baseTagsWithNodeInfo...), + TagKeys: append([]tag.Key{census.kPipeline, census.kModelName}, baseTags...), Aggregation: view.LastValue(), }, { diff --git a/server/ai_http.go b/server/ai_http.go index fab8b8eb4a..ee60603c28 100644 --- a/server/ai_http.go +++ b/server/ai_http.go @@ -3,6 +3,7 @@ package server import ( "context" "encoding/json" + "errors" "fmt" "image" "net/http" @@ -271,6 +272,7 @@ func handleAIRequest(ctx context.Context, w http.ResponseWriter, r *http.Request start := time.Now() resp, err := submitFn(ctx) + err = errors.New("fake error for testing") if err != nil { if monitor.Enabled { monitor.AIProcessingError(err.Error(), pipeline, modelID, sender.Hex())