Skip to content

Commit

Permalink
[3185] Unify pipeline tag on prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
pwilczynskiclearcode committed Oct 2, 2024
1 parent 93bec37 commit fc8bf4a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions server/ai_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,30 +633,30 @@ func submitSegmentAnything2(ctx context.Context, params aiRequestParams, sess *A
mw, err := worker.NewSegmentAnything2MultipartWriter(&buf, req)
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "segment anything 2", *req.ModelId, sess.OrchestratorInfo)
monitor.AIRequestError(err.Error(), "segment-anything-2", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}

client, err := worker.NewClientWithResponses(sess.Transcoder(), worker.WithHTTPClient(httpClient))
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "segment anything 2", *req.ModelId, sess.OrchestratorInfo)
monitor.AIRequestError(err.Error(), "segment-anything-2", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}

imageRdr, err := req.Image.Reader()
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "segment anything 2", *req.ModelId, sess.OrchestratorInfo)
monitor.AIRequestError(err.Error(), "segment-anything-2", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}
config, _, err := image.DecodeConfig(imageRdr)
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "segment anything 2", *req.ModelId, sess.OrchestratorInfo)
monitor.AIRequestError(err.Error(), "segment-anything-2", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}
Expand All @@ -665,7 +665,7 @@ func submitSegmentAnything2(ctx context.Context, params aiRequestParams, sess *A
setHeaders, balUpdate, err := prepareAIPayment(ctx, sess, outPixels)
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "segment anything 2", *req.ModelId, sess.OrchestratorInfo)
monitor.AIRequestError(err.Error(), "segment-anything-2", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}
Expand All @@ -676,7 +676,7 @@ func submitSegmentAnything2(ctx context.Context, params aiRequestParams, sess *A
took := time.Since(start)
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "segment anything 2", *req.ModelId, sess.OrchestratorInfo)
monitor.AIRequestError(err.Error(), "segment-anything-2", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}
Expand All @@ -700,7 +700,7 @@ func submitSegmentAnything2(ctx context.Context, params aiRequestParams, sess *A
pricePerAIUnit = float64(priceInfo.PricePerUnit) / float64(priceInfo.PixelsPerUnit)
}

monitor.AIRequestFinished(ctx, "segment anything 2", *req.ModelId, monitor.AIJobInfo{LatencyScore: sess.LatencyScore, PricePerUnit: pricePerAIUnit}, sess.OrchestratorInfo)
monitor.AIRequestFinished(ctx, "segment-anything-2", *req.ModelId, monitor.AIJobInfo{LatencyScore: sess.LatencyScore, PricePerUnit: pricePerAIUnit}, sess.OrchestratorInfo)
}

return resp.JSON200, nil
Expand Down Expand Up @@ -1045,6 +1045,7 @@ func processAIRequest(ctx context.Context, params aiRequestParams, req interface
}
capName := cap.String()
ctx = clog.AddVal(ctx, "capability", capName)
pipelineTag := strings.Replace(strings.ToLower(cap.String()), " ", "-", -1)

var resp interface{}

Expand All @@ -1057,7 +1058,7 @@ func processAIRequest(ctx context.Context, params aiRequestParams, req interface
case <-cctx.Done():
err := fmt.Errorf("no orchestrators available within %v timeout", processingRetryTimeout)
if monitor.Enabled {
monitor.AIRequestError(err.Error(), capName, modelID, nil)
monitor.AIRequestError(err.Error(), pipelineTag, modelID, nil)
}
return nil, &ServiceUnavailableError{err: err}
default:
Expand Down Expand Up @@ -1095,7 +1096,7 @@ func processAIRequest(ctx context.Context, params aiRequestParams, req interface
if resp == nil {
errMsg := "no orchestrators available"
if monitor.Enabled {
monitor.AIRequestError(errMsg, capName, modelID, nil)
monitor.AIRequestError(errMsg, pipelineTag, modelID, nil)
}
return nil, &ServiceUnavailableError{err: errors.New(errMsg)}
}
Expand Down

0 comments on commit fc8bf4a

Please sign in to comment.