Skip to content

Commit

Permalink
cache won't be hit if tags order are not the same
Browse files Browse the repository at this point in the history
  • Loading branch information
iqbalaydrus committed Nov 15, 2023
1 parent 17d71f6 commit e8f98bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/zabbix/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zabbix

import (
"context"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -402,6 +403,13 @@ func (ds *Zabbix) GetAllItems(ctx context.Context, hostids []string, appids []st
}
tagsParams = append(tagsParams, tagParam)
}
// tags order should be handled for higher cache hit ratio
sort.Slice(tagsParams, func(i, j int) bool {
if tagsParams[i]["tag"] != tagsParams[j]["tag"] {
return tagsParams[i]["tag"] < tagsParams[j]["tag"]
}
return tagsParams[i]["value"] < tagsParams[j]["value"]
})
params["tags"] = tagsParams
params["evaltype"] = 2
}
Expand Down

0 comments on commit e8f98bd

Please sign in to comment.