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) {
|
func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, modelName string) {
|
||||||
// set minimal group ratio as channel_ratio
|
// set minimal group ratio as channel_ratio
|
||||||
var minimalRatio float64
|
var minimalRatio float64 = -1
|
||||||
for _, grp := range strings.Split(channel.Group, ",") {
|
for _, grp := range strings.Split(channel.Group, ",") {
|
||||||
v := common.GetGroupRatio(grp)
|
v := common.GetGroupRatio(grp)
|
||||||
if minimalRatio == 0 || v < minimalRatio {
|
if minimalRatio < 0 || v < minimalRatio {
|
||||||
minimalRatio = v
|
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_ratio", minimalRatio)
|
||||||
|
|
||||||
c.Set("channel", channel.Type)
|
c.Set("channel", channel.Type)
|
||||||
|
|||||||
Reference in New Issue
Block a user