@@ -3,11 +3,11 @@ package extproc
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
- "log"
7
6
"strings"
8
7
9
8
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/config"
10
9
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/metrics"
10
+ "github.com/vllm-project/semantic-router/src/semantic-router/pkg/observability"
11
11
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/utils/entropy"
12
12
)
13
13
@@ -24,7 +24,7 @@ func (r *OpenAIRouter) getReasoningModeAndCategory(query string) (bool, string)
24
24
25
25
// If no category was determined (empty string), default to no reasoning
26
26
if categoryName == "" {
27
- log . Printf ("No category determined for query, defaulting to no reasoning mode" )
27
+ observability . Infof ("No category determined for query, defaulting to no reasoning mode" )
28
28
return false , ""
29
29
}
30
30
@@ -38,14 +38,14 @@ func (r *OpenAIRouter) getReasoningModeAndCategory(query string) (bool, string)
38
38
if category .UseReasoning {
39
39
reasoningStatus = "ENABLED"
40
40
}
41
- log . Printf ("Reasoning mode decision: Category '%s' → %s" ,
41
+ observability . Infof ("Reasoning mode decision: Category '%s' → %s" ,
42
42
categoryName , reasoningStatus )
43
43
return category .UseReasoning , categoryName
44
44
}
45
45
}
46
46
47
47
// If category not found in config, default to no reasoning
48
- log . Printf ("Category '%s' not found in configuration, defaulting to no reasoning mode" , categoryName )
48
+ observability . Infof ("Category '%s' not found in configuration, defaulting to no reasoning mode" , categoryName )
49
49
return false , categoryName
50
50
}
51
51
@@ -55,7 +55,7 @@ func (r *OpenAIRouter) getEntropyBasedReasoningModeAndCategory(query string) (bo
55
55
categoryName , confidence , reasoningDecision , err := r .Classifier .ClassifyCategoryWithEntropy (query )
56
56
57
57
if err != nil {
58
- log . Printf ("Entropy-based classification error: %v, falling back to traditional method" , err )
58
+ observability . Warnf ("Entropy-based classification error: %v, falling back to traditional method" , err )
59
59
60
60
// Record fallback metrics
61
61
metrics .RecordEntropyFallback ("classification_error" , "traditional_method" )
@@ -74,12 +74,12 @@ func (r *OpenAIRouter) getEntropyBasedReasoningModeAndCategory(query string) (bo
74
74
}
75
75
76
76
// Log the entropy-based decision
77
- log . Printf ("Entropy-based reasoning decision: category='%s', confidence=%.3f, use_reasoning=%t, reason=%s, strategy=%s" ,
77
+ observability . Infof ("Entropy-based reasoning decision: category='%s', confidence=%.3f, use_reasoning=%t, reason=%s, strategy=%s" ,
78
78
categoryName , confidence , reasoningDecision .UseReasoning , reasoningDecision .DecisionReason , reasoningDecision .FallbackStrategy )
79
79
80
80
// If we have top categories from entropy analysis, log them
81
81
if len (reasoningDecision .TopCategories ) > 0 {
82
- log . Printf ("Top predicted categories: %v" , reasoningDecision .TopCategories )
82
+ observability . Infof ("Top predicted categories: %v" , reasoningDecision .TopCategories )
83
83
}
84
84
85
85
return reasoningDecision .UseReasoning , categoryName , reasoningDecision
@@ -181,11 +181,11 @@ func (r *OpenAIRouter) setReasoningModeToRequestBody(requestBody []byte, enabled
181
181
182
182
// Log based on what actually happened
183
183
if enabled && ! reasoningApplied {
184
- log . Printf ("No reasoning support for model: %s (no reasoning family configured)" , model )
184
+ observability . Infof ("No reasoning support for model: %s (no reasoning family configured)" , model )
185
185
} else if reasoningApplied {
186
- log . Printf ("Applied reasoning mode (enabled: %v) with effort (%s) to model: %s" , enabled , appliedEffort , model )
186
+ observability . Infof ("Applied reasoning mode (enabled: %v) with effort (%s) to model: %s" , enabled , appliedEffort , model )
187
187
} else {
188
- log . Printf ("Reasoning mode disabled for model: %s" , model )
188
+ observability . Infof ("Reasoning mode disabled for model: %s" , model )
189
189
}
190
190
191
191
// Record metrics for template usage and effort when enabled
@@ -228,7 +228,7 @@ func (r *OpenAIRouter) setReasoningModeToRequestBody(requestBody []byte, enabled
228
228
// logReasoningConfiguration logs the reasoning mode configuration for all categories during startup
229
229
func (r * OpenAIRouter ) logReasoningConfiguration () {
230
230
if len (r .Config .Categories ) == 0 {
231
- log . Printf ("No categories configured for reasoning mode" )
231
+ observability . Infof ("No categories configured for reasoning mode" )
232
232
return
233
233
}
234
234
@@ -243,14 +243,14 @@ func (r *OpenAIRouter) logReasoningConfiguration() {
243
243
}
244
244
}
245
245
246
- log . Printf ("Reasoning configuration - Total categories: %d" , len (r .Config .Categories ))
246
+ observability . Infof ("Reasoning configuration - Total categories: %d" , len (r .Config .Categories ))
247
247
248
248
if len (reasoningEnabled ) > 0 {
249
- log . Printf ("Reasoning ENABLED for categories (%d): %v" , len (reasoningEnabled ), reasoningEnabled )
249
+ observability . Infof ("Reasoning ENABLED for categories (%d): %v" , len (reasoningEnabled ), reasoningEnabled )
250
250
}
251
251
252
252
if len (reasoningDisabled ) > 0 {
253
- log . Printf ("Reasoning DISABLED for categories (%d): %v" , len (reasoningDisabled ), reasoningDisabled )
253
+ observability . Infof ("Reasoning DISABLED for categories (%d): %v" , len (reasoningDisabled ), reasoningDisabled )
254
254
}
255
255
}
256
256
@@ -266,7 +266,7 @@ func (r *OpenAIRouter) ClassifyAndDetermineReasoningMode(query string) (string,
266
266
if useReasoning {
267
267
reasoningStatus = "enabled"
268
268
}
269
- log . Printf ("Model selection complete: model=%s, reasoning=%s" , bestModel , reasoningStatus )
269
+ observability . Infof ("Model selection complete: model=%s, reasoning=%s" , bestModel , reasoningStatus )
270
270
271
271
return bestModel , useReasoning
272
272
}
@@ -284,7 +284,7 @@ func (r *OpenAIRouter) LogReasoningConfigurationSummary() {
284
284
}
285
285
}
286
286
287
- log . Printf ("Reasoning mode summary: %d/%d categories have reasoning enabled" , enabledCount , len (r .Config .Categories ))
287
+ observability . Infof ("Reasoning mode summary: %d/%d categories have reasoning enabled" , enabledCount , len (r .Config .Categories ))
288
288
}
289
289
290
290
// getReasoningEffort returns the reasoning effort level for a given category
0 commit comments