99 "github.com/prometheus/client_golang/prometheus/promauto"
1010
1111 "github.com/vllm-project/semantic-router/src/semantic-router/pkg/config"
12+ "github.com/vllm-project/semantic-router/src/semantic-router/pkg/consts"
1213)
1314
1415// Minimal fallback bucket configurations - used only when configuration is completely missing
@@ -384,18 +385,18 @@ var (
384385// RecordModelRequest increments the counter for requests to a specific model
385386func RecordModelRequest (model string ) {
386387 if model == "" {
387- model = "unknown"
388+ model = consts . UnknownLabel
388389 }
389390 ModelRequests .WithLabelValues (model ).Inc ()
390391}
391392
392393// RecordRequestError increments request error counters labeled by model and normalized reason
393394func RecordRequestError (model , reason string ) {
394395 if model == "" {
395- model = "unknown"
396+ model = consts . UnknownLabel
396397 }
397398 if reason == "" {
398- reason = "unknown"
399+ reason = consts . UnknownLabel
399400 }
400401 // Normalize a few common variants to canonical reasons
401402 switch reason {
@@ -435,10 +436,10 @@ func RecordModelCost(model string, currency string, amount float64) {
435436// RecordRoutingReasonCode increments the counter for a routing decision reason code and model
436437func RecordRoutingReasonCode (reasonCode , model string ) {
437438 if reasonCode == "" {
438- reasonCode = "unknown"
439+ reasonCode = consts . UnknownLabel
439440 }
440441 if model == "" {
441- model = "unknown"
442+ model = consts . UnknownLabel
442443 }
443444 RoutingReasonCodes .WithLabelValues (reasonCode , model ).Inc ()
444445}
@@ -453,7 +454,7 @@ func RecordModelTokensDetailed(model string, promptTokens, completionTokens floa
453454
454455 // Also record per-request histograms for visibility into distribution
455456 if model == "" {
456- model = "unknown"
457+ model = consts . UnknownLabel
457458 }
458459 PromptTokensPerRequest .WithLabelValues (model ).Observe (promptTokens )
459460 CompletionTokensPerRequest .WithLabelValues (model ).Observe (completionTokens )
@@ -470,7 +471,7 @@ func RecordModelTTFT(model string, seconds float64) {
470471 return
471472 }
472473 if model == "" {
473- model = "unknown"
474+ model = consts . UnknownLabel
474475 }
475476 ModelTTFT .WithLabelValues (model ).Observe (seconds )
476477}
@@ -481,7 +482,7 @@ func RecordModelTPOT(model string, secondsPerToken float64) {
481482 return
482483 }
483484 if model == "" {
484- model = "unknown"
485+ model = consts . UnknownLabel
485486 }
486487 ModelTPOT .WithLabelValues (model ).Observe (secondsPerToken )
487488}
@@ -515,7 +516,7 @@ func UpdateCacheEntries(backend string, count int) {
515516// RecordCategoryClassification increments the counter for a specific category classification
516517func RecordCategoryClassification (category string ) {
517518 if category == "" {
518- category = "unknown"
519+ category = consts . UnknownLabel
519520 }
520521 CategoryClassificationsCount .WithLabelValues (category ).Inc ()
521522}
@@ -575,7 +576,7 @@ func GetBatchSizeRange(size int) string {
575576 }
576577
577578 // Fallback for unexpected cases
578- return "unknown"
579+ return consts . UnknownLabel
579580}
580581
581582// GetBatchSizeRangeFromBuckets generates range labels based on size buckets
@@ -756,7 +757,7 @@ func RecordReasoningDecision(category, model string, enabled bool, effort string
756757// RecordReasoningTemplateUsage records usage of a model-family-specific template parameter
757758func RecordReasoningTemplateUsage (family , param string ) {
758759 if family == "" {
759- family = "unknown"
760+ family = consts . UnknownLabel
760761 }
761762 if param == "" {
762763 param = "none"
@@ -767,7 +768,7 @@ func RecordReasoningTemplateUsage(family, param string) {
767768// RecordReasoningEffortUsage records the effort usage by model family
768769func RecordReasoningEffortUsage (family , effort string ) {
769770 if family == "" {
770- family = "unknown"
771+ family = consts . UnknownLabel
771772 }
772773 if effort == "" {
773774 effort = "unspecified"
@@ -778,7 +779,7 @@ func RecordReasoningEffortUsage(family, effort string) {
778779// RecordEntropyClassificationDecision records an entropy-based classification decision
779780func RecordEntropyClassificationDecision (uncertaintyLevel string , reasoningEnabled bool , decisionReason string , topCategory string ) {
780781 if uncertaintyLevel == "" {
781- uncertaintyLevel = "unknown"
782+ uncertaintyLevel = consts . UnknownLabel
782783 }
783784 if decisionReason == "" {
784785 decisionReason = "unspecified"
@@ -798,7 +799,7 @@ func RecordEntropyClassificationDecision(uncertaintyLevel string, reasoningEnabl
798799// RecordEntropyValue records the entropy value for a classification
799800func RecordEntropyValue (category string , classificationType string , entropyValue float64 ) {
800801 if category == "" {
801- category = "unknown"
802+ category = consts . UnknownLabel
802803 }
803804 if classificationType == "" {
804805 classificationType = "standard"
@@ -810,7 +811,7 @@ func RecordEntropyValue(category string, classificationType string, entropyValue
810811// RecordClassificationConfidence records the confidence score from classification
811812func RecordClassificationConfidence (category string , classificationMethod string , confidence float64 ) {
812813 if category == "" {
813- category = "unknown"
814+ category = consts . UnknownLabel
814815 }
815816 if classificationMethod == "" {
816817 classificationMethod = "traditional"
@@ -827,10 +828,10 @@ func RecordEntropyClassificationLatency(seconds float64) {
827828// RecordProbabilityDistributionQuality records quality checks for probability distributions
828829func RecordProbabilityDistributionQuality (qualityCheck string , status string ) {
829830 if qualityCheck == "" {
830- qualityCheck = "unknown"
831+ qualityCheck = consts . UnknownLabel
831832 }
832833 if status == "" {
833- status = "unknown"
834+ status = consts . UnknownLabel
834835 }
835836
836837 ProbabilityDistributionQuality .WithLabelValues (qualityCheck , status ).Inc ()
@@ -839,7 +840,7 @@ func RecordProbabilityDistributionQuality(qualityCheck string, status string) {
839840// RecordEntropyFallback records when entropy-based routing falls back to traditional methods
840841func RecordEntropyFallback (fallbackReason string , fallbackStrategy string ) {
841842 if fallbackReason == "" {
842- fallbackReason = "unknown"
843+ fallbackReason = consts . UnknownLabel
843844 }
844845 if fallbackStrategy == "" {
845846 fallbackStrategy = "unspecified"
0 commit comments