-
Notifications
You must be signed in to change notification settings - Fork 98
ACLP Alerting go SDK #824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ACLP Alerting go SDK #824
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces ACLP (Alerting Linode Platform) SDK functionality to the linodego client library, adding support for monitor alert definitions and channels. The implementation includes API client methods, data structures, and comprehensive test coverage.
- Adds monitor alert definitions CRUD operations with support for v4beta API endpoints
- Implements monitor channels functionality for alert notification management
- Provides comprehensive unit and integration test coverage for all new functionality
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| monitor_alert_definitions.go | Core implementation of alert definitions API client methods and data structures |
| monitor_channels.go | Monitor channels API client methods and channel management functionality |
| request_helpers.go | New helper function for v4beta API endpoint formatting |
| test/unit/base.go | Enhanced test base to support v4beta endpoint mocking |
| test/unit/monitor_alert_definitions_test.go | Comprehensive unit tests for alert definitions functionality |
| test/integration/monitor_alert_definitions_test.go | Integration test with real API interaction scenarios |
| test/integration/fixtures/TestMonitorAlertDefinition_instance.yaml | Test fixture data for integration testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
9226cfb to
8e71881
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 77 out of 81 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
yec-akamai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems some unrelated commits are added accidentally. Do you mind cleaning up the branch and fixing the conflicts?
|
@srbhaakamai Just bumping Ye's comment — could you resolve the conflicts and unrelated comments on this branch? I'm happy to do it too and push up the new commit if you'd like |
7818a6b to
aed99f8
Compare
|
@srbhaakamai I just finished up fixing up the commit history and will be providing a review shortly 👍 |
| func formatAPIV4BetaPath(format string, args ...any) string { | ||
| p := formatAPIPath(format, args...) | ||
|
|
||
| // Ensure we don't produce a double slash when joining | ||
| p = strings.TrimPrefix(p, "/") | ||
|
|
||
| return fmt.Sprintf("%s://%s/%s/%s", APIProto, APIHost, "v4beta", p) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we put the responsibility on users to configure v4beta using either LINODE_API_VERSION or the Client{}.SetVersion(...) / Client{}.UseURL(...) if they want to access beta endpoints. If a user wants to use just a couple of v4beta endpoints and run everything else under v4, we generally recommend that they create two separate clients.
The idea is that users will be required to acknowledge that they're using beta endpoints rather than it happening without them knowing. I'll take a note to document this a bit more explicitly 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Threshold: func(f float64) *float64 { return &f }(90.0), | ||
| Unit: func(s string) *string { return &s }("percent"), |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Using inline anonymous functions to get pointers is verbose and reduces readability. Consider adding helper functions like Float64Ptr and StringPtr in a test utilities file, similar to common patterns in other Go SDKs.
| // Exponential backoff, capped at 30s | ||
| sleep := baseDelay * (1 << attempt) |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exponential backoff calculation 1 << attempt can overflow for large attempt values. Since the loop doesn't explicitly limit the number of attempts (only time-based), this could potentially cause a panic. Consider adding a maximum attempt counter or using a safer calculation method.
| // Exponential backoff, capped at 30s | |
| sleep := baseDelay * (1 << attempt) | |
| // Exponential backoff, capped at 30s and prevent shift overflow | |
| cappedAttempt := attempt | |
| if cappedAttempt > 5 { // 1 << 5 = 32, so max multiplier is 32 | |
| cappedAttempt = 5 | |
| } | |
| sleep := baseDelay * (1 << cappedAttempt) |
📝 Description
Provide go SDK support to ACLP clients to perform CRUD operations for Alerts.
✔️ How to Test
How do I run the relevant unit/integration tests?
Prerequisites
Go 1.19+ installed
Valid Linode API token with monitor permissions
Export LINODE_TOKEN environment variable for integration tests
Run all monitor alert definition unit tests:
UNIT TEST:
go test ./test/unit -run ".MonitorAlertDefinition." -v
Expected Output:
✅ TestCreateMonitorAlertDefinition
✅ TestCreateMonitorAlertDefinitionWithIdempotency
✅ TestGetMonitorAlertDefinition
✅ TestListMonitorAlertDefinitions
✅ TestUpdateMonitorAlertDefinition
✅ TestUpdateMonitorAlertDefinition_LabelOnly
✅ TestDeleteMonitorAlertDefinition
INTEGRATION TEST:
export LINODE_TOKEN="your-linode-api-token"
go test ./test/integration -run "TestMonitorAlertDefinition_smoke" -v
Test Coverage:
List Operations: Validates fetching existing alert definitions
Channel Discovery: Finds available alert channels for testing
Create: Tests complex alert definition creation with:
TriggerConditions (evaluation periods, polling intervals)
RuleCriteria with Rules (metrics, operators, thresholds)
DimensionFilters (node type filtering)
Update: Tests label-only updates with proper timing
Delete: Tests cleanup with exponential backoff retry logic
Expected Duration: ~102 seconds (includes API timing requirements)
📷 Preview
If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.