chore: fix logging and std out printing - #2798
Conversation
📊 API Diff Results
|
There was a problem hiding this comment.
🟡 Changes recommended
The new noteStyler.Write can drop buffered output on write errors due to advancing the pending buffer before confirming writes succeed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refines the CLI’s human-facing output (notes + tables) while tightening time-bound handling around recorder start times, aiming to make logs more readable and reduce false “from before recording started” failures caused by sub-second header timestamps.
Changes:
- Compare
fromvsStartedAtat whole-second granularity (and update error formatting to RFC3339Nano) with added unit tests for boundary cases. - Improve operator-facing output formatting: multi-line startup summary, earlier
min-observednote, titled tables, and a structured THRESHOLDS section. - Add a CLI-only notes/table styling layer (ANSI color when writing to a terminal; plain text otherwise) and route
Notesthrough it incheckandwatch.
File summaries
| File | Description |
|---|---|
| grafana-alertcheck/internal/gate/schedule.go | Makes startup summary/warning multi-line and more readable. |
| grafana-alertcheck/internal/gate/coverage.go | Applies whole-second comparison for from bounds; uses RFC3339Nano in message. |
| grafana-alertcheck/internal/gate/coverage_test.go | Adds tests covering same-second and boundary-crossing cases for from bounds. |
| grafana-alertcheck/internal/gate/check.go | Uses whole-second comparison for recorder-mode fail-fast; prints min-observed earlier. |
| grafana-alertcheck/internal/gate/check_test.go | Adds recorder-mode test ensuring same-second from passes. |
| grafana-alertcheck/cmd/grafana-alertcheck/watch.go | Routes gate notes through the new note styler. |
| grafana-alertcheck/cmd/grafana-alertcheck/check.go | Routes gate notes through the new note styler. |
| grafana-alertcheck/cmd/grafana-alertcheck/table.go | Adds section titles, thresholds table, and colored “violations” footer when terminal output. |
| grafana-alertcheck/cmd/grafana-alertcheck/table_test.go | Updates assertions for the new table/footer format. |
| grafana-alertcheck/cmd/grafana-alertcheck/style.go | Introduces terminal-detection, note line styling, and section spacing behavior. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e0a1a11 to
24afb29
Compare
24afb29 to
bb77d7f
Compare
Improves human-facing output for
check/watch:style.gonoteStylercolourises notes by prefix and inserts section breaks — colour only when the destination is a TTY andNO_COLORis unset.table.gooutput is restructured into titled sections (RESULTS / VIOLATIONS / THRESHOLDS) with a coloured violations footer.from < StartedAtbound is now compared at whole-second granularity (incoverage.goand thecheck.gofail-fast), so a--fromin the same second as the recording's start is not judged early.StartupSummaryis reformatted onto multiple lines.Review focus:
style.go(colour/NO_COLOR) and the whole-second truncation incoverage.go/check.go.