@@ -58,7 +58,7 @@ func (ch *ConcurrencyHandler) EvaluateAndAdjustConcurrency(resp *http.Response,
58
58
// Calculate the cumulative score.
59
59
cumulativeScore := weightedRateLimitScore + weightedResponseCodeScore + weightedResponseTimeScore
60
60
61
- // Log the feedback from each monitoring function for debugging.
61
+ // Detailed debugging output
62
62
ch .logger .Debug ("Evaluate and Adjust Concurrency" ,
63
63
zap .String ("event" , "EvaluateConcurrency" ),
64
64
zap .Float64 ("weightedRateLimitScore" , weightedRateLimitScore ),
@@ -71,6 +71,14 @@ func (ch *ConcurrencyHandler) EvaluateAndAdjustConcurrency(resp *http.Response,
71
71
zap .Duration ("responseTime" , responseTime ),
72
72
)
73
73
74
+ // Check for successful response and log appropriately
75
+ if responseCodeFeedback == 1 { // Assuming 1 indicates success
76
+ ch .logger .Info ("Successful response noted, checking for scaling necessity." ,
77
+ zap .String ("API Response" , "Success" ),
78
+ zap .Int ("StatusCode" , resp .StatusCode ),
79
+ )
80
+ }
81
+
74
82
// Check critical thresholds
75
83
if rateLimitFeedback <= RateLimitCriticalThreshold || weightedResponseCodeScore >= ErrorResponseThreshold {
76
84
ch .logger .Warn ("Scaling down due to critical threshold breach" ,
@@ -82,7 +90,7 @@ func (ch *ConcurrencyHandler) EvaluateAndAdjustConcurrency(resp *http.Response,
82
90
return
83
91
}
84
92
85
- // Evaluate cumulative impact and make a scaling decision.
93
+ // Evaluate cumulative impact and make a scaling decision based on the cumulative score and other metrics .
86
94
if cumulativeScore < 0 {
87
95
utilizedBefore := len (ch .sem ) // Tokens in use before scaling down.
88
96
ch .ScaleDown ()
@@ -170,9 +178,10 @@ func (ch *ConcurrencyHandler) MonitorServerResponseCodes(resp *http.Response) in
170
178
zap .Float64 ("ErrorRate" , errorRate ),
171
179
)
172
180
181
+ // Only suggest a scale-down if the error rate exceeds the threshold
173
182
if errorRate > ErrorRateThreshold {
174
183
return - 1
175
- } else if errorRate <= ErrorRateThreshold && len (ch .sem ) < MaxConcurrency {
184
+ } else if len (ch .sem ) < MaxConcurrency {
176
185
return 1
177
186
}
178
187
return 0
0 commit comments