Skip to content

Grafana datasource plugin for B2C Commerce (Metrics + CIP) with Go SDK#571

Draft
clavery wants to merge 1 commit into
mainfrom
feature/grafana
Draft

Grafana datasource plugin for B2C Commerce (Metrics + CIP) with Go SDK#571
clavery wants to merge 1 commit into
mainfrom
feature/grafana

Conversation

@clavery

@clavery clavery commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a Grafana datasource plugin for B2C Commerce with two datasource types, plus a standalone Go SDK that powers them (and is reusable for other Go tooling). Verified end-to-end against a live instance.

New packages

  • packages/b2c-tooling-sdk-go — standalone Go SDK (git-tag versioned): OAuth client-credentials auth, a Metrics REST client (with transparent >24h range partitioning + typed HTTPError), a CIP Avatica/protobuf client, tenant/window helpers, and tag enrichment kept byte-parity with the TS SDK via a golden fixture.
  • packages/b2c-grafana-datasource — the plugin (git-tag versioned), shipping two datasource types from one workspace package:
    • Metrics (SCAPI Observability): tiered push-down/label filters, metric multi-select, group-by legends, live discovery + template variables.
    • CIP (Commerce Intelligence): raw Calcite SQL built on grafana/sqlds/v4 (the framework the built-in Postgres/MySQL datasources use) — $__timeFilter/$__timeGroup/$__interval macros, schema browser, template variables.
    • React query editors, a multi-stage Docker demo (synthetic mock and live-instance mode), and merchant + technical dashboards.

Also

  • @salesforce/b2c-tooling-sdk: metrics tag enrichment refactored into a declarative catalog + golden fixture (the shared source of truth the Go SDK consumes). No API change (see changeset).
  • Error-source attribution (429 → downstream, not a plugin fault), authoritative RefID keying, sqlds row limits/timeouts, idempotent timestamp normalization.
  • CI: a test-go job builds/vets/tests both Go modules; a catalog-parity test guards TS↔Go drift.

Versioning

The Grafana plugin and Go SDK are git-tag versioned (like b2c-vs-extension), not changesets. The changeset in this PR covers only the @salesforce/b2c-tooling-sdk enrichment change.

Manual testing

Requires Docker and the b2c CLI configured for a B2C instance with the Metrics closed beta enabled and CIP access.

cd packages/b2c-grafana-datasource
make demo                    # synthetic data, no credentials — open http://localhost:3000
make real INSTANCE=<name>    # live instance (creds sourced from the b2c CLI keychain)

In Grafana (http://localhost:3000, anonymous admin):

  • Open the provisioned dashboards (Metrics demo, CIP merchant, CIP technical) and confirm panels render.
  • Metrics editor: pick a category + metric(s), add server/label filters, group-by; confirm a "Last 7 days" range works (partitioned).
  • CIP editor: run a $__timeGroupAlias(col, $__interval) + $__timeFilter(col) query in both Time series and Table format; use the schema browser and a $site template variable.
  • make down to tear down.

Draft — opening for review of the overall architecture and to run CI. Rate-limit resilience (retry/caching) is planned separately in packages/b2c-grafana-datasource/RESILIENCE_PLAN.md.

Add a Grafana datasource plugin for B2C Commerce with two datasource types
and a standalone Go SDK that powers them:

- packages/b2c-tooling-sdk-go — Go SDK (OAuth client-credentials, Metrics
  REST client with >24h range partitioning + typed HTTPError, CIP Avatica
  client, tenant/window helpers, tag enrichment with TS↔Go golden parity).
- packages/b2c-grafana-datasource — plugin with a Metrics datasource
  (tiered push-down/label filters, metric multi-select, group-by, discovery)
  and a CIP SQL datasource built on grafana/sqlds/v4 (Calcite time macros,
  schema browser, template variables). React query editors; multi-stage
  Docker demo (mock) + real mode (creds via b2c CLI keychain); merchant +
  technical dashboards.
- b2c-tooling-sdk: tag enrichment refactored to a declarative catalog +
  golden fixture (shared source of truth for the Go SDK).

Correctness/idiom hardening: error-source attribution (429 -> downstream),
authoritative RefID keying, idempotent timestamp normalization, sqlds row
limits/timeouts. CI runs Go build/vet/test for both modules; catalog parity
test guards TS<->Go drift. Both Go modules versioned via git tags.

Verified end-to-end against a live instance (Metrics + CIP, dashboards,
discovery, variables).
@github-actions github-actions Bot added the needs-3pl-review PR introduces net-new third-party dependencies and needs discussion label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-3pl-review PR introduces net-new third-party dependencies and needs discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant