Skip to content

Commit

Permalink
refactor: improve orchestrator metrics tags
Browse files Browse the repository at this point in the history
This commit ensures that the right tags are attached to the Orchestrator
AI metrics.
  • Loading branch information
rickstaa committed Jul 17, 2024
1 parent a3f7d53 commit 7bfdd45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions monitor/census.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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(),
},
{
Expand Down
2 changes: 2 additions & 0 deletions server/ai_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"context"
"encoding/json"
"errors"
"fmt"
"image"
"net/http"
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 7bfdd45

Please sign in to comment.