Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cli/src/types/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ function extractFunctionName(aggregate: string): string {
* Example: `p50(value,completion.duration_ms,distribution,none)`
*/
function isTracemetricsAggregate(aggregate: string): boolean {
// equation| prefix denotes a formula combining multiple tracemetrics aggregates
if (aggregate.startsWith("equation|")) {
return true;
}
const parenIdx = aggregate.indexOf("(");
if (parenIdx < 0) {
return false;
Expand Down
29 changes: 29 additions & 0 deletions packages/cli/test/types/dashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
TABLE_DISPLAY_TYPES,
type TextResult,
TIMESERIES_DISPLAY_TYPES,
validateAggregateNames,
validateWidgetLayout,
WIDGET_TYPES,
type WidgetDataResult,
Expand Down Expand Up @@ -963,6 +964,34 @@ describe("mapWidgetTypeToDataset", () => {
});
});

describe("validateAggregateNames", () => {
test("accepts comma-separated tracemetrics aggregates", () => {
expect(() =>
validateAggregateNames(
["p50(value,completion.duration_ms,distribution,none)"],
"tracemetrics"
)
).not.toThrow();
});

test("accepts equation| formula aggregates for tracemetrics", () => {
expect(() =>
validateAggregateNames(
[
"equation|p50(value,a,distribution,none) / p50(value,b,distribution,none)",
],
"tracemetrics"
)
).not.toThrow();
});

test("rejects span-style aggregates for tracemetrics", () => {
expect(() => validateAggregateNames(["count()"], "tracemetrics")).toThrow(
ValidationError
);
});
});

// ---------------------------------------------------------------------------
// validateWidgetLayout
// ---------------------------------------------------------------------------
Expand Down
Loading