mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-14 16:12:15 +01:00
app/vmselect/graphite: extract getCanonicalPath() function from loop body inside getCanonicalPaths()
This commit is contained in:
parent
79cd33319f
commit
5856611291
@ -366,26 +366,29 @@ func TagsFindSeriesHandler(startTime time.Time, at *auth.Token, w http.ResponseW
|
|||||||
|
|
||||||
func getCanonicalPaths(mns []storage.MetricName) []string {
|
func getCanonicalPaths(mns []storage.MetricName) []string {
|
||||||
paths := make([]string, 0, len(mns))
|
paths := make([]string, 0, len(mns))
|
||||||
var b []byte
|
|
||||||
var tags []storage.Tag
|
|
||||||
for _, mn := range mns {
|
for _, mn := range mns {
|
||||||
b = append(b[:0], mn.MetricGroup...)
|
path := getCanonicalPath(&mn)
|
||||||
tags = append(tags[:0], mn.Tags...)
|
paths = append(paths, path)
|
||||||
sort.Slice(tags, func(i, j int) bool {
|
|
||||||
return string(tags[i].Key) < string(tags[j].Key)
|
|
||||||
})
|
|
||||||
for _, tag := range tags {
|
|
||||||
b = append(b, ';')
|
|
||||||
b = append(b, tag.Key...)
|
|
||||||
b = append(b, '=')
|
|
||||||
b = append(b, tag.Value...)
|
|
||||||
}
|
|
||||||
paths = append(paths, string(b))
|
|
||||||
}
|
}
|
||||||
sort.Strings(paths)
|
sort.Strings(paths)
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCanonicalPath(mn *storage.MetricName) string {
|
||||||
|
b := append([]byte{}, mn.MetricGroup...)
|
||||||
|
tags := append([]storage.Tag{}, mn.Tags...)
|
||||||
|
sort.Slice(tags, func(i, j int) bool {
|
||||||
|
return string(tags[i].Key) < string(tags[j].Key)
|
||||||
|
})
|
||||||
|
for _, tag := range tags {
|
||||||
|
b = append(b, ';')
|
||||||
|
b = append(b, tag.Key...)
|
||||||
|
b = append(b, '=')
|
||||||
|
b = append(b, tag.Value...)
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|
||||||
var tagsFindSeriesDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/tags/findSeries"}`)
|
var tagsFindSeriesDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/tags/findSeries"}`)
|
||||||
|
|
||||||
// TagValuesHandler implements /tags/<tag_name> endpoint from Graphite Tags API.
|
// TagValuesHandler implements /tags/<tag_name> endpoint from Graphite Tags API.
|
||||||
|
Loading…
Reference in New Issue
Block a user