feat(billing): GCP BigQuery billing-export cost source - #27
Merged
Conversation
Adds a billing.Source that reads real net cost (list cost plus credits) from the standard GCP billing export in BigQuery, grouped by service, as the GCP counterpart to the AWS Cost Explorer source. Selectable via CLOUDORACLE_BILLING_PROVIDER=gcp_bigquery; reports data_source billing_gcp_bigquery. - internal/billing/bigquery.go: BigQuerySource with a narrow bigQueryAPI seam (returns parsed rows) so tests run offline; real client wraps *bigquery.Client via ADC. - config: gcp_bigquery enum + CLOUDORACLE_GCP_BILLING_DATASET/_TABLE, with a cross-field check requiring project+dataset+table. - main: billing wiring switch gains the GCP case with loud snapshot fallback on init failure. - docs + agent knowledge + README roadmap updated.
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 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
Adds a
billing.Sourcethat reads real net cost (list cost + credits) from the standard GCP billing export in BigQuery, grouped by service — the GCP counterpart to the existing AWS Cost Explorer source.Selectable via
CLOUDORACLE_BILLING_PROVIDER=gcp_bigquery; the v1 cost endpoints then reportdata_source: billing_gcp_bigquery.How
internal/billing/bigquery.go—BigQuerySourceimplementsbilling.Source. A narrowbigQueryAPIseam returns already-parsed(service, cost)rows so unit tests run fully offline (same flattening trick the GCP inventory listers use); the real client wraps*bigquery.Clientvia Application Default Credentials.SUM(cost + IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0))grouped byservice.description, filtered on theusage_start_timepartition column.config:gcp_bigqueryenum +CLOUDORACLE_GCP_BILLING_DATASET/CLOUDORACLE_GCP_BILLING_TABLE, with a cross-field check requiring project + dataset + table.main: billing wiring became aswitchwith the GCP case; loud fallback to thesnapshotsapproximation on init failure (never refuses to start).configuration.md,cloud-providers.md), agent knowledge (data-sources-and-caveats.md), and the README roadmap updated.Tests
internal/billing(sum/normalize, SQL bounds+table, error-wrap) andinternal/config(cross-field required/OK) green; fullgo build ./...clean.🤖 Generated with Claude Code