MCPcopy Create free account
hub / github.com/github/gh-aw / scanSteeringEntries

Function scanSteeringEntries

pkg/cli/token_usage.go:833–852  ·  view source on GitHub ↗

scanSteeringEntries reads all valid steering proxyEventsEntry records from r. Lines that fail the quick-keyword check or JSON decoding are silently skipped. The caller is responsible for the lifetime of r.

(r io.Reader)

Source from the content-addressed store, hash-verified

831// Lines that fail the quick-keyword check or JSON decoding are silently skipped.
832// The caller is responsible for the lifetime of r.
833func scanSteeringEntries(r io.Reader) ([]proxyEventsEntry, error) {
834 var entries []proxyEventsEntry
835 scanner := bufio.NewScanner(r)
836 buf := make([]byte, maxScannerBufferSize)
837 scanner.Buffer(buf, maxScannerBufferSize)
838 for scanner.Scan() {
839 line := strings.TrimSpace(scanner.Text())
840 if line == "" || !containsSteeringKeyword(line) {
841 continue
842 }
843 var entry proxyEventsEntry
844 if err := json.Unmarshal([]byte(line), &entry); err != nil {
845 continue
846 }
847 if isSteeringEvent(entry.eventName(), strings.TrimSpace(entry.Message)) {
848 entries = append(entries, entry)
849 }
850 }
851 return entries, scanner.Err()
852}
853
854func parseAPIProxySteeringEvents(filePath string) (int, error) {
855 file, err := os.Open(filepath.Clean(filePath))

Callers 2

Calls 3

eventNameMethod · 0.95
containsSteeringKeywordFunction · 0.85
isSteeringEventFunction · 0.85

Tested by

no test coverage detected