MCPcopy Create free account
hub / github.com/prometheus/procfs / parseCounters

Function parseCounters

bcachefs/get.go:302–325  ·  view source on GitHub ↗
(countersPath string)

Source from the content-addressed store, hash-verified

300}
301
302func parseCounters(countersPath string) (map[string]CounterStats, error) {
303 entries, err := os.ReadDir(countersPath)
304 if err != nil {
305 if os.IsNotExist(err) {
306 return nil, nil
307 }
308 return nil, err
309 }
310
311 stats := make(map[string]CounterStats, len(entries))
312 for _, entry := range entries {
313 if entry.IsDir() {
314 continue
315 }
316 counterPath := filepath.Join(countersPath, entry.Name())
317 counter, err := parseCounterFile(counterPath)
318 if err != nil {
319 return nil, err
320 }
321 stats[entry.Name()] = counter
322 }
323
324 return stats, nil
325}
326
327func parseCounterFile(path string) (CounterStats, error) {
328 file, err := openIfExists(path)

Callers 1

readFilesystemStatsMethod · 0.85

Calls 2

parseCounterFileFunction · 0.85
NameMethod · 0.80

Tested by

no test coverage detected