Skip to content

feat: add ordinal event dimension column - #40

Open
abnegate wants to merge 1 commit into
mainfrom
feat/event-ordinal-dimension
Open

feat: add ordinal event dimension column#40
abnegate wants to merge 1 commit into
mainfrom
feat/event-ordinal-dimension

Conversation

@abnegate

@abnegate abnegate commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Add ordinal to EVENT_COLUMNS, the event schema, and event indexes so additive counters (dedicated-database inbound / outbound / compute) can split per member the way gauges already do.
  • setup() ADD COLUMN IF NOT EXISTSs it onto existing event tables. The daily MV stays grouped on resource identity only, so a billing sum without an ordinal filter still totals every member.

Test plan

  • tests/Usage/MetricTest.php and ClickHouseColumnTypeTest.php (56 tests)
  • testEventOrdinalSeparatesReplicaSeries against ClickHouse (filter / groupBy / unsplit sum)

Made with Cursor

Gauges already split multi-node resources on ordinal. Counters such as
dedicated-database inbound, outbound and compute need the same column so
a chart can tell members apart. setup() adds it to existing event tables.
The daily MV stays grouped on resource identity only, so billing still
sums every member.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR promotes replica ordinal from a gauge-only dimension to a shared event and gauge dimension.

  • Adds ordinal to event validation, extraction, schema, and index definitions.
  • Makes existing ClickHouse event tables acquire the column during setup while preserving ordinal-unsplit daily billing totals.
  • Simplifies the Database adapter’s shared schema now that the event schema includes ordinal.
  • Adds schema, extraction, column-type, filtering, grouping, and total-sum coverage.

Confidence Score: 5/5

The PR appears safe to merge; ordinal remains distinct in raw event series while unfiltered daily billing totals continue to include every member.

The dimension is aligned across validation, extraction, schemas, indexes, adapters, and tests. Existing Database collections already had ordinal through the former gauge-specific setup, and ClickHouse correctly routes ordinal-dependent queries away from the daily table that intentionally omits it.

Important Files Changed

Filename Overview
src/Usage/Metric.php Adds ordinal consistently across the event dimension contract, schema, extraction, accessor documentation, and indexes.
src/Usage/Adapter/Database.php Removes the redundant gauge-only ordinal schema append now that the event schema supplies the shared field and index.
src/Usage/Adapter/ClickHouse.php Updates ordinal classification for event and gauge schemas without changing daily-rollup grouping or routing behavior.
tests/Usage/Adapter/ClickHouseTest.php Covers raw event filtering and grouping by ordinal while confirming an unsplit sum still totals all members.
tests/Usage/MetricTest.php Updates the metric contract tests to verify ordinal as a shared event and gauge dimension.

Reviews (1): Last reviewed commit: "feat: add ordinal event dimension column" | Re-trigger Greptile

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