mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-09 02:03:42 +08:00
fix: Refactor: Migrate Distributor logging to ratio metrics
- Log a ratio for each channel in the context - Initialize `minimalRatio` to -1 instead of 0
This commit is contained in:
@@ -86,13 +86,14 @@ func Distribute() func(c *gin.Context) {
|
||||
|
||||
func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, modelName string) {
|
||||
// set minimal group ratio as channel_ratio
|
||||
var minimalRatio float64
|
||||
var minimalRatio float64 = -1
|
||||
for _, grp := range strings.Split(channel.Group, ",") {
|
||||
v := common.GetGroupRatio(grp)
|
||||
if minimalRatio == 0 || v < minimalRatio {
|
||||
if minimalRatio < 0 || v < minimalRatio {
|
||||
minimalRatio = v
|
||||
}
|
||||
}
|
||||
logger.Info(c.Request.Context(), fmt.Sprintf("set channel %s ratio to %f", channel.Name, minimalRatio))
|
||||
c.Set("channel_ratio", minimalRatio)
|
||||
|
||||
c.Set("channel", channel.Type)
|
||||
|
||||
Reference in New Issue
Block a user