-
Notifications
You must be signed in to change notification settings - Fork 19
feat: new Fastly plugin #67
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
Open
spa-raj
wants to merge
8
commits into
opencost:main
Choose a base branch
from
spa-raj:fastly-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
Signed-off-by: Sparsh <[email protected]>
This commit implements a Fastly plugin for OpenCost that integrates with the Fastly billing API to retrieve and display cloud costs. The plugin: 1. Fetches invoice data from Fastly's API (both historical and month-to-date) 2. Converts Fastly billing items to OpenCost's CustomCost model 3. Implements proper rate limiting to respect Fastly API constraints 4. Caches invoice data to minimize redundant API calls 5. Prorates costs across time windows when invoice periods don't align with requested time ranges The plugin allows OpenCost users to monitor and analyze their Fastly CDN costs alongside other cloud expenses. Signed-off-by: Sparsh <[email protected]>
Signed-off-by: Sparsh <[email protected]>
Signed-off-by: Sparsh <[email protected]>
This commit implements several key improvements to the Fastly OpenCost plugin: Core Enhancements: - Replace shared invoice IDs with unique UUIDs for each cost item using github.com/google/uuid - Update rate limiting from 600 to 5400 requests per minute to better utilize Fastly's 6000 req/min limit - Add comprehensive request validation with proper error handling for edge cases Performance & Reliability: - Implement invoice caching to reduce redundant API calls - Batch invoice fetching for entire periods instead of per-window requests - Add proper future date handling (return empty response instead of errors) - Enhanced error logging with more descriptive messages Testing Improvements: - Add comprehensive test coverage with TestUniqueUUIDGeneration - Replace transport mocking with HTTPClient interface for better testability - Add request validation tests covering all edge cases - Include test utilities and mock data generation tools API Integration: - Remove redundant Host headers from API requests - Improve charge categorization (commitment, credit, support, tax, usage) - Enhanced usage unit mapping for better cost attribution - Add support for credits/discounts with proper labeling Signed-off-by: Sparsh <[email protected]>
Signed-off-by: Sparsh <[email protected]>
…ended attributes for the same Signed-off-by: Sparsh <[email protected]>
Signed-off-by: Sparsh <[email protected]>
@ameijer Can you approve this backend workflow? It's been a while. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR change?
Core Plugin Implementation:
FastlyConfig
struct infastlyconfig.go
to hold plugin configuration such as API key and log level.invoices.go
, including robust handling for themonthly_transaction_amount
field which may arrive as a number or string from the API.Validation and Testing:
main.go
) that reads daily and hourly protobuf files, validates the responses for expected structure and values, and checks for errors or anomalies in cost data.fastly_test.go
to verify correct plugin behavior across daily, hourly, future, and month-to-date cost retrieval scenarios.Supporting Files and Dependencies:
fastly_daily_test.json
,fastly_hourly_test.json
) for use in validation and testing. [1] [2]go.mod
.Does this PR relate to any other PRs?
How will this PR impact users?
Does this PR address any GitHub or Zendesk issues?
How was this PR tested?
All tests pass: ✅ 25/25 unit tests + 4/4 harness tests + validator tests
Does this PR require changes to documentation?