Skip to content

feat(billing): GCP BigQuery billing-export cost source - #27

Merged
Cro22 merged 1 commit into
feature/3.0from
feat/gcp-billing-bigquery
Aug 24, 2026
Merged

feat(billing): GCP BigQuery billing-export cost source#27
Cro22 merged 1 commit into
feature/3.0from
feat/gcp-billing-bigquery

Conversation

@Cro22

@Cro22 Cro22 commented Aug 24, 2026

Copy link
Copy Markdown
Owner

What

Adds a billing.Source that 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 report data_source: billing_gcp_bigquery.

How

  • internal/billing/bigquery.goBigQuerySource implements billing.Source. A narrow bigQueryAPI seam 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.Client via Application Default Credentials.
  • Net cost SQL: SUM(cost + IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) grouped by service.description, filtered on the usage_start_time partition column.
  • config: gcp_bigquery enum + CLOUDORACLE_GCP_BILLING_DATASET / CLOUDORACLE_GCP_BILLING_TABLE, with a cross-field check requiring project + dataset + table.
  • main: billing wiring became a switch with the GCP case; loud fallback to the snapshots approximation on init failure (never refuses to start).
  • Docs (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) and internal/config (cross-field required/OK) green; full go build ./... clean.

🤖 Generated with Claude Code

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.
@Cro22
Cro22 merged commit 6427431 into feature/3.0 Aug 24, 2026
Cro22 added a commit that referenced this pull request Aug 25, 2026
The stacked PRs #29/#30/#31 merged into their intermediate bases rather
than cascading to feature/3.0, leaving M1 (google_compute_disk), M2
(google_sql_database_instance), and M3 (docs) stranded. This completes the
stack onto feature/3.0 alongside the already-landed billing (#27) and
compute (#28).
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