Skip to content

Commit 5c113d0

Browse files
committed
feat(adapter): add p_by_resourceId gauge projection; refresh legacy-gauge test fixture
Accelerates the gauge "top consumers by resource" panel that the console queries via dimensions=['resourceId']. resourceId is high- cardinality (one per file / function / bucket) but gauges are sparse (one snapshot per resource per interval, not per request), so the projection stays small relative to events. Same argMaxState(value, time) aggregator as the existing gauge projections. The legacy-gauge schema fixture in ClickHouseSchemaTest predates this projection slate and omitted the resourceId / teamId columns that v0.3.0 already declared. Updated it to match the 0.3.0 schema so setup() can attach the new projection during the upgrade test. Considered an analogous events-side `p_by_endpoint(method, status, path)` projection for the console TopRequests panel (dimensions= ['path','method','status']). Path is high-cardinality so the projection's row count would approximately equal the raw events table — adding ~30% storage for a column-IO win of ~3-5x rather than the 20-50x the other projections deliver. Deferred in favour of having the console switch to single-dim ['path'] queries against the existing p_by_path projection.
1 parent 958596b commit 5c113d0

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/Usage/Adapter/ClickHouse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ private function formatParamValue(mixed $value): string
10501050
private const GAUGE_PROJECTIONS = [
10511051
['name' => 'p_by_service', 'dims' => ['service']],
10521052
['name' => 'p_by_resource', 'dims' => ['resource']],
1053+
['name' => 'p_by_resourceId', 'dims' => ['resourceId']],
10531054
];
10541055

10551056
/**

tests/Usage/Adapter/ClickHouseSchemaTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ public function testSetupBackfillsServiceResourceOnLegacyGaugesTable(): void
114114
metric String,
115115
value Int64,
116116
time DateTime64(3),
117+
resourceId Nullable(String),
118+
resourceInternalId Nullable(String),
119+
teamId Nullable(String),
120+
teamInternalId Nullable(String),
117121
tenant Nullable(String)
118122
)
119123
ENGINE = MergeTree()

0 commit comments

Comments
 (0)