(path string)
| 262 | } |
| 263 | |
| 264 | func parseErrors(path string) (map[string]ErrorStats, error) { |
| 265 | file, err := openIfExists(path) |
| 266 | if err != nil { |
| 267 | return nil, err |
| 268 | } |
| 269 | if file == nil { |
| 270 | return map[string]ErrorStats{}, nil |
| 271 | } |
| 272 | defer file.Close() |
| 273 | |
| 274 | stats := make(map[string]ErrorStats) |
| 275 | |
| 276 | scanner := bufio.NewScanner(file) |
| 277 | for scanner.Scan() { |
| 278 | line := scanner.Text() |
| 279 | fields := strings.Fields(line) |
| 280 | if len(fields) < 2 { |
| 281 | continue |
| 282 | } |
| 283 | count, err := strconv.ParseUint(fields[1], 10, 64) |
| 284 | if err != nil { |
| 285 | return nil, err |
| 286 | } |
| 287 | var ts uint64 |
| 288 | if len(fields) >= 3 { |
| 289 | ts, err = strconv.ParseUint(fields[2], 10, 64) |
| 290 | if err != nil { |
| 291 | return nil, err |
| 292 | } |
| 293 | } |
| 294 | stats[fields[0]] = ErrorStats{Count: count, Timestamp: ts} |
| 295 | } |
| 296 | if err := scanner.Err(); err != nil { |
| 297 | return nil, err |
| 298 | } |
| 299 | return stats, nil |
| 300 | } |
| 301 | |
| 302 | func parseCounters(countersPath string) (map[string]CounterStats, error) { |
| 303 | entries, err := os.ReadDir(countersPath) |
no test coverage detected