This repository was archived by the owner on Jun 23, 2026. It is now read-only.
feat: add Monitor V2 subcommands - #10
Open
beengud wants to merge 1 commit into
Open
Conversation
* feat: implement observe list monitor and observe get monitor (Monitor V2) Add ot_monitorv2.go defining the 'monitor' object type backed by the searchMonitorV2 and monitorV2 GraphQL queries. Add cmd_monitorv2.go registering the 'monitor' command with preview-query, preview, and alarms subcommands, using cfg.WorkspaceIdOrName (global --workspace flag) with a default of workspace 42379913. Add docs/monitor.md and comprehensive unit tests in cmd_monitorv2_test.go covering all subcommands, empty results, multiple groupings, and error paths. Closes #15 * feat: add comprehensive unit test coverage for monitor V2 commands Review existing monitor V2 tests and add missing coverage: - TestCmdListMonitorDisabledTrue/False: verify disabled field rendering - TestCmdMonitorPreviewQueryInvalidJSON: error on bad JSON input - TestCmdMonitorPreviewInvalidJSON: error on bad JSON input - TestCmdMonitorAlarmsSingleGrouping: single-grouping alarm in table - TestMonitorV2FromObjectHelper: direct helper function tests - TestMonitorV2FromObjectHelperNilFields: nil-safe field handling - TestCmdGetMonitorDefinitionJSON: definition JSON in get output - TestCmdMonitorPreviewQueryEmptyFields: empty result schema fields - TestCmdMonitorAlarmsNoSamples: alarm with null groupings field All 31 monitor-related tests pass. Closes #19 * feat: add integration tests for monitor V2 commands against live tenant Add cmd_monitorv2_integration_test.go with //go:build integration tag. Tests cover all four monitor V2 GraphQL operations against workspace 42379913: - TestIntegrationListMonitors: searchMonitorV2, tolerates empty result; if monitors exist, gets the first one by ID via monitorV2 query - TestIntegrationSearchAlarms: searchMonitorV2Alarms for all time, skips gracefully if API is unavailable - TestIntegrationPreviewQuery: evaluateMonitorV2Source using stub JSON, skipped if stub input is invalid for the tenant - TestIntegrationPreview: previewMonitorV2 using stub JSON, skipped if stub input is invalid for the tenant Add testdata/monitor_input_stub.json: a minimal MonitorV2Input definition for use in preview-query and preview integration tests. Run with: go test -tags integration ./... Closes #20 * fix: rename integrationConfig to integrationMonitorConfig to avoid redeclaration The integrationConfig function in cmd_dataset_integration_test.go (added in an earlier MR) uses no args. This file's integrationConfig(t *testing.T) caused a redeclaration compile error under the integration build tag. Rename to integrationMonitorConfig to resolve the conflict. --------- Co-authored-by: Aaron Brewbaker <abrewbaker@nhl.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
observesubcommands for Monitor V2 management and alarm inspection:observe list monitorobserve get monitor <id>observe monitor preview-query <file.json>observe monitor preview <file.json>observe monitor alarms [--monitor <id>] [--since <dur>] [--level <l>]The preview commands are useful for validating monitor definitions before saving, and for debugging why a monitor did or didn't fire during an incident.
Files
cmd_monitorv2.go— CLI command handlersot_monitorv2.go— GraphQL operationscmd_monitorv2_test.go— unit testscmd_monitorv2_integration_test.go— integration tests (build tag:integration)testdata/monitor_input_stub.json— example monitor definitiondocs/monitor.md— usage documentation