Skip to content

feat(gateway): add metrics query commands (Phase 5a-E)#222

Merged
leggetter merged 7 commits intomainfrom
feat/metrics
Feb 26, 2026
Merged

feat(gateway): add metrics query commands (Phase 5a-E)#222
leggetter merged 7 commits intomainfrom
feat/metrics

Conversation

@leggetter
Copy link
Collaborator

Summary

Adds hookdeck gateway metrics with 7 subcommands for querying Event Gateway metrics (events, requests, attempts, queue-depth, pending, events-by-issue, transformations).

Changes

  • API client (pkg/hookdeck/metrics.go): 7 methods, shared MetricsQueryParams, response parsing (including transformations { data: [] } wrapper).
  • Command group (pkg/cmd/metrics.go): gateway metrics with common flags --start, --end (required), --granularity, --measures, --dimensions, --source-id, --destination-id, --connection-id, --status, --output.
  • Per-endpoint commands: metrics_events.go, metrics_requests.go, metrics_attempts.go, metrics_queue_depth.go, metrics_pending.go, metrics_events_by_issue.go, metrics_transformations.go.
  • events-by-issue: Takes <issue-id> as positional argument (no --issue-id flag) for consistency with other resource-id-as-argument commands.
  • Tests: test/acceptance/metrics_test.go — help, 7 baseline, common-flag, validation (missing --start/--end/--measures, missing issue-id for events-by-issue), and JSON output (~27 tests). All passing.
  • Docs: REFERENCE.md updated with metrics use-case table and one example per subcommand.

Plan

Implements Phase 5a-E (metrics querying) from the CLI updates plan. API requires date_range and measures; events-by-issue requires issue ID (CLI: positional <issue-id>).

Made with Cursor

leggetter and others added 7 commits February 24, 2026 15:09
Previously, pagination cursors (next/prev) were not displayed to users
in CLI output, even though they were available in the API responses.
This made it impossible to paginate through large result sets.

Changes:
- Created pkg/cmd/pagination_output.go with helper functions:
  - printPaginationInfo() for text output
  - marshalListResponseWithPagination() for JSON output
- Updated all 8 list commands to display pagination info:
  - event list
  - request list
  - attempt list
  - transformation list
  - transformation executions
  - connection list
  - source list
  - destination list
- Fixed JSON output to always include pagination metadata
  (previously returned [] for empty results)
- Updated test helper functions to handle new JSON response format
- Added comprehensive pagination acceptance tests for:
  - event list (TestEventListPaginationWorkflow)
  - request list (TestRequestListPaginationWorkflow)
  - attempt list (TestAttemptListPaginationWorkflow)
- Updated TestEventListJSON to verify pagination metadata

Fixes #216
- Add pkg/hookdeck/metrics.go: 7 API methods, MetricsQueryParams, response parsing
- Add gateway metrics command group with shared flags (--start, --end, --granularity, --measures, --dimensions, filters)
- Add 7 subcommands: events, requests, attempts, queue-depth, pending, events-by-issue, transformations
- events-by-issue takes <issue-id> as positional argument; other commands use optional filter flags
- Add test/acceptance/metrics_test.go: help, baseline, common flags, validation, JSON output (~27 tests)
- Update REFERENCE.md with metrics use-case table and examples

Implements Phase 5a-E metrics plan. API requires date range and measures; events-by-issue requires issue ID.

Made-with: Cursor
Use ShortBeta and LongBeta on all 7 metrics subcommands so help text
shows [BETA] and feedback link, consistent with other gateway commands.

Made-with: Cursor
Fixes in tools/generate-reference/main.go for correct generation of CLI metrics docs (e.g. usage line escaping, table formatting). No CLI binary change; docs generator only.

Made-with: Cursor
@leggetter leggetter merged commit 2ca70f0 into main Feb 26, 2026
7 checks passed
@leggetter leggetter deleted the feat/metrics branch February 26, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant