Skip to content

refactor(gateway_logs): replace manual ASCII table with console.RenderTable#21216

Merged
pelikhan merged 2 commits intomainfrom
copilot/refactor-gateway-logs-table
Mar 16, 2026
Merged

refactor(gateway_logs): replace manual ASCII table with console.RenderTable#21216
pelikhan merged 2 commits intomainfrom
copilot/refactor-gateway-logs-table

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

renderGatewayMetricsTable in pkg/cli/gateway_logs.go built tables manually using Unicode box-drawing characters and fixed-width fmt.Fprintf column alignment. Replaces both tables (server metrics and per-server tool details) with console.RenderTable, gaining TTY-aware rendering, adaptive colors, and consistent border styling.

Changes

  • Server Usage table: replaces ~15 lines of box-drawing with console.RenderTable(TableConfig{Title: "Server Usage", Headers: [...]})
  • Tool Usage tables (verbose): same replacement, one table per server using server name as Title
  • Removed stringutil import — fixed-width truncation for manual column alignment no longer needed
  • Added strconv import — strconv.Itoa replaces fmt.Sprintf("%d", ...) per linter (perfsprint)
// Before
output.WriteString("┌────────────────────────────┬──────────┬────────────┬───────────┬────────┐\n")
output.WriteString("│ Server                     │ Requests │ Tool Calls │ Avg Time  │ Errors │\n")
// ...
fmt.Fprintf(&output, "│ %-26s │ %8d │ %10d │ %7.0fms │ %6d │\n", ...)

// After
output.WriteString(console.RenderTable(console.TableConfig{
    Title:   "Server Usage",
    Headers: []string{"Server", "Requests", "Tool Calls", "Avg Time", "Errors"},
    Rows:    serverRows,
}))

Copilot AI and others added 2 commits March 16, 2026 11:40
…erTable

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 16, 2026 12:08
Copilot AI review requested due to automatic review settings March 16, 2026 12:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors gateway metrics output to use console.RenderTable instead of manually building fixed-width Unicode tables, improving consistency and TTY-aware styling.

Changes:

  • Replaced the “Server Usage” metrics table rendering with console.RenderTable.
  • Replaced per-server “Tool Usage” verbose tables with console.RenderTable.
  • Updated imports (removed stringutil, added strconv) to support the new formatting approach.
Comments suppressed due to low confidence (1)

pkg/cli/gateway_logs.go:568

  • Previously tool names were truncated (24 chars) to keep the per-server tool table width bounded. Passing toolName through unmodified can produce very wide tables for long tool identifiers. Consider truncating tool names before adding them to toolRows (or supporting max column widths in console.RenderTable).
				toolRows = append(toolRows, []string{
					toolName,
					strconv.Itoa(tool.CallCount),
					fmt.Sprintf("%.0fms", tool.AvgDuration),
					fmt.Sprintf("%.0fms", tool.MaxDuration),
					strconv.Itoa(tool.ErrorCount),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +527 to +532
serverRows = append(serverRows, []string{
serverName,
strconv.Itoa(server.RequestCount),
strconv.Itoa(server.ToolCallCount),
fmt.Sprintf("%.0fms", avgTime),
strconv.Itoa(server.ErrorCount),
@pelikhan pelikhan merged commit da0e655 into main Mar 16, 2026
90 checks passed
@pelikhan pelikhan deleted the copilot/refactor-gateway-logs-table branch March 16, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Refactor gateway_logs.go manual ASCII table to use console.RenderTable

3 participants