You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/semantic-router/pkg/metrics/metrics.go
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,15 @@ var (
102
102
[]string{"model"},
103
103
)
104
104
105
+
// RequestErrorsTotal tracks request errors categorized by reason
106
+
RequestErrorsTotal=promauto.NewCounterVec(
107
+
prometheus.CounterOpts{
108
+
Name: "llm_request_errors_total",
109
+
Help: "The total number of request errors categorized by reason (e.g., timeout, upstream_5xx, pii_policy_denied, jailbreak_block, parse_error, serialization_error, cancellation)",
110
+
},
111
+
[]string{"model", "reason"},
112
+
)
113
+
105
114
// ModelCost tracks the total cost attributed to each model by currency
106
115
ModelCost=promauto.NewCounterVec(
107
116
prometheus.CounterOpts{
@@ -353,9 +362,32 @@ var (
353
362
354
363
// RecordModelRequest increments the counter for requests to a specific model
355
364
funcRecordModelRequest(modelstring) {
365
+
ifmodel=="" {
366
+
model="unknown"
367
+
}
356
368
ModelRequests.WithLabelValues(model).Inc()
357
369
}
358
370
371
+
// RecordRequestError increments request error counters labeled by model and normalized reason
372
+
funcRecordRequestError(model, reasonstring) {
373
+
ifmodel=="" {
374
+
model="unknown"
375
+
}
376
+
ifreason=="" {
377
+
reason="unknown"
378
+
}
379
+
// Normalize a few common variants to canonical reasons
0 commit comments