| 168 | } |
| 169 | |
| 170 | func inferFallbackLogMetrics(logsPath string) (LogMetrics, string) { |
| 171 | if logsPath == "" { |
| 172 | return LogMetrics{}, "" |
| 173 | } |
| 174 | |
| 175 | if eventsJSONLPath := findEventsJSONLFile(logsPath); eventsJSONLPath != "" { |
| 176 | if metrics, err := parseEventsJSONLMetrics(eventsJSONLPath, false); err == nil && hasUsefulFallbackMetrics(metrics) { |
| 177 | return metrics, "copilot" |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | agentLogPath := findAgentStdioLogPath(logsPath) |
| 182 | if agentLogPath == "" { |
| 183 | return LogMetrics{}, "" |
| 184 | } |
| 185 | content, err := os.ReadFile(agentLogPath) |
| 186 | if err != nil { |
| 187 | return LogMetrics{}, "" |
| 188 | } |
| 189 | return inferBestEngineMetricsFromContent(string(content)) |
| 190 | } |
| 191 | |
| 192 | func findAgentStdioLogPath(logsPath string) string { |
| 193 | root := filepath.Join(logsPath, "agent-stdio.log") |