Skip to content

Commit

Permalink
Sort scrapers by name (#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flashy78 authored May 3, 2023
1 parent d6b4d16 commit 1606f1b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/scraper/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func (c *Cache) loadScrapers() (map[string]scraper, error) {

logger.Debugf("Reading scraper configs from %s", path)

scraperFiles := []string{}
err := fsutil.SymWalk(path, func(fp string, f os.FileInfo, err error) error {
if filepath.Ext(fp) == ".yml" {
conf, err := loadConfigFromYAMLFile(fp)
Expand All @@ -160,7 +159,6 @@ func (c *Cache) loadScrapers() (map[string]scraper, error) {
scraper := newGroupScraper(*conf, c.globalConfig)
scrapers[scraper.spec().ID] = scraper
}
scraperFiles = append(scraperFiles, fp)
}
return nil
})
Expand All @@ -187,7 +185,7 @@ func (c *Cache) ReloadScrapers() error {
}

// ListScrapers lists scrapers matching one of the given types.
// Returns a list of scrapers, sorted by their ID.
// Returns a list of scrapers, sorted by their name.
func (c Cache) ListScrapers(tys []ScrapeContentType) []*Scraper {
var ret []*Scraper
for _, s := range c.scrapers {
Expand All @@ -201,7 +199,7 @@ func (c Cache) ListScrapers(tys []ScrapeContentType) []*Scraper {
}

sort.Slice(ret, func(i, j int) bool {
return ret[i].ID < ret[j].ID
return strings.ToLower(ret[i].Name) < strings.ToLower(ret[j].Name)
})

return ret
Expand Down

0 comments on commit 1606f1b

Please sign in to comment.