Skip to content

Commit 3e15d82

Browse files
refactor: use new group limit in explorer (#698)
* refactor: use new group limit in explorer * test: fix up explorer query handler test * test: more cleanup
1 parent 04e3ff5 commit 3e15d82

20 files changed

+80
-121
lines changed

projects/observability/src/pages/explorer/explorer-dashboard-builder.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ describe('Explorer dashboard builder', () => {
8787
const mockRequest: ExploreVisualizationRequest = {
8888
context: ObservabilityTraceType.Api,
8989
series: [series],
90+
resultLimit: 1000,
9091
exploreQuery$: EMPTY,
9192
resultsQuery$: of({
9293
requestType: TRACES_GQL_REQUEST,

projects/observability/src/pages/explorer/explorer.component.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('Explorer component', () => {
138138
expect.objectContaining({
139139
requestType: EXPLORE_GQL_REQUEST,
140140
context: ObservabilityTraceType.Api,
141-
limit: 500,
141+
limit: 1000,
142142
interval: new TimeDuration(15, TimeUnit.Second)
143143
}),
144144
expect.objectContaining({})
@@ -186,7 +186,7 @@ describe('Explorer component', () => {
186186
requestType: EXPLORE_GQL_REQUEST,
187187
context: ObservabilityTraceType.Api,
188188
filters: [new GraphQlFieldFilter('first', GraphQlOperatorType.Equals, 'foo')],
189-
limit: 500,
189+
limit: 1000,
190190
interval: new TimeDuration(15, TimeUnit.Second)
191191
}),
192192
expect.objectContaining({})
@@ -222,7 +222,7 @@ describe('Explorer component', () => {
222222
expect.objectContaining({
223223
requestType: EXPLORE_GQL_REQUEST,
224224
context: SPAN_SCOPE,
225-
limit: 500,
225+
limit: 1000,
226226
interval: new TimeDuration(15, TimeUnit.Second)
227227
}),
228228
expect.objectContaining({})
@@ -274,7 +274,7 @@ describe('Explorer component', () => {
274274
expect.objectContaining({
275275
requestType: EXPLORE_GQL_REQUEST,
276276
context: SPAN_SCOPE,
277-
limit: 500,
277+
limit: 1000,
278278
interval: new TimeDuration(15, TimeUnit.Second),
279279
filters: [new GraphQlFieldFilter('first', GraphQlOperatorType.Equals, 'foo')]
280280
}),

projects/observability/src/shared/components/explore-query-editor/explore-query-editor.component.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ describe('Explore query editor', () => {
174174
expect(onRequestChange).toHaveBeenLastCalledWith(
175175
expect.objectContaining({
176176
series: [defaultSeries],
177-
groupByLimit: 5, // Default group by limit
178177
groupBy: {
179-
keys: ['first groupable']
178+
keys: ['first groupable'],
179+
limit: 5 // Default group by limit
180180
}
181181
})
182182
);
@@ -213,9 +213,9 @@ describe('Explore query editor', () => {
213213
expect(onQueryChange).toHaveBeenLastCalledWith(
214214
expect.objectContaining({
215215
series: [defaultSeries],
216-
groupByLimit: 6,
217216
groupBy: {
218-
keys: ['first groupable']
217+
keys: ['first groupable'],
218+
limit: 6
219219
}
220220
})
221221
);

projects/observability/src/shared/components/explore-query-editor/explore-query-editor.component.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,20 @@ import {
4444
></ht-explore-query-group-by-editor>
4545
4646
<ht-explore-query-limit-editor
47+
*ngIf="currentVisualization.groupBy"
4748
class="limit"
48-
[limit]="currentVisualization.groupByLimit"
49-
(limitChange)="this.setLimit($event)"
49+
[limit]="currentVisualization.groupBy?.limit"
50+
(limitChange)="this.updateGroupByLimit(currentVisualization.groupBy!, $event)"
5051
[includeRest]="currentVisualization.groupBy?.includeRest"
5152
(includeRestChange)="this.updateGroupByIncludeRest(currentVisualization.groupBy!, $event)"
52-
[disabled]="!currentVisualization.groupBy"
5353
>
5454
</ht-explore-query-limit-editor>
5555
</div>
5656
</div>
5757
`
5858
})
5959
export class ExploreQueryEditorComponent implements OnChanges, OnInit {
60+
private static readonly DEFAULT_GROUP_LIMIT: number = 5;
6061
@Input()
6162
public filters?: Filter[];
6263

@@ -94,16 +95,18 @@ export class ExploreQueryEditorComponent implements OnChanges, OnInit {
9495
if (key === undefined) {
9596
this.visualizationBuilder.groupBy();
9697
} else {
97-
this.visualizationBuilder.groupBy(groupBy ? { ...groupBy, keys: [key] } : { keys: [key] });
98+
this.visualizationBuilder.groupBy(
99+
groupBy ? { ...groupBy, keys: [key] } : { keys: [key], limit: ExploreQueryEditorComponent.DEFAULT_GROUP_LIMIT }
100+
);
98101
}
99102
}
100103

101104
public updateGroupByIncludeRest(groupBy: GraphQlGroupBy, includeRest: boolean): void {
102105
this.visualizationBuilder.groupBy({ ...groupBy, includeRest: includeRest });
103106
}
104107

105-
public setLimit(limit: number): void {
106-
this.visualizationBuilder.groupByLimit(limit);
108+
public updateGroupByLimit(groupBy: GraphQlGroupBy, limit: number): void {
109+
this.visualizationBuilder.groupBy({ ...groupBy, limit: limit });
107110
}
108111

109112
public setInterval(interval: IntervalValue): void {

projects/observability/src/shared/components/explore-query-editor/explore-visualization-builder.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,23 @@ describe('Explore visualization builder', () => {
8383
spectator.service
8484
.setSeries([buildSeries('test1')])
8585
.groupBy({
86-
keys: ['testGroupBy']
86+
keys: ['testGroupBy'],
87+
limit: 15
8788
})
88-
.groupByLimit(15)
8989
.setSeries([buildSeries('test2')]);
9090

91-
expectObservable(recordedRequests).toBe('(abcde)', {
91+
expectObservable(recordedRequests).toBe('(abcd)', {
9292
a: expectedQuery(),
9393
b: expectedQuery({
9494
series: [matchSeriesWithName('test1')]
9595
}),
9696
c: expectedQuery({
9797
series: [matchSeriesWithName('test1')],
98-
groupBy: { keys: ['testGroupBy'] },
99-
groupByLimit: 5
98+
groupBy: { keys: ['testGroupBy'], limit: 15 }
10099
}),
101100
d: expectedQuery({
102-
series: [matchSeriesWithName('test1')],
103-
groupBy: { keys: ['testGroupBy'] },
104-
groupByLimit: 15
105-
}),
106-
e: expectedQuery({
107101
series: [matchSeriesWithName('test2')],
108-
groupBy: { keys: ['testGroupBy'] },
109-
groupByLimit: 15
102+
groupBy: { keys: ['testGroupBy'], limit: 15 }
110103
})
111104
});
112105
});

projects/observability/src/shared/components/explore-query-editor/explore-visualization-builder.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import { CartesianSeriesVisualizationType } from '../cartesian/chart';
3030

3131
@Injectable()
3232
export class ExploreVisualizationBuilder implements OnDestroy {
33-
private static readonly DEFAULT_GROUP_LIMIT: number = 5;
34-
private static readonly DEFAULT_UNGROUPED_LIMIT: number = 500;
33+
private static readonly DEFAULT_LIMIT: number = 1000;
3534

3635
public readonly visualizationRequest$: Observable<ExploreVisualizationRequest>;
3736
private readonly destroyed$: Subject<void> = new Subject();
@@ -80,20 +79,8 @@ export class ExploreVisualizationBuilder implements OnDestroy {
8079
}
8180

8281
public groupBy(groupBy?: GraphQlGroupBy): this {
83-
const groupByLimit =
84-
this.currentState().groupByLimit !== undefined
85-
? this.currentState().groupByLimit
86-
: ExploreVisualizationBuilder.DEFAULT_GROUP_LIMIT;
87-
88-
return this.updateState({
89-
groupBy: groupBy,
90-
groupByLimit: groupBy && groupByLimit
91-
});
92-
}
93-
94-
public groupByLimit(limit: number): this {
9582
return this.updateState({
96-
groupByLimit: limit
83+
groupBy: groupBy
9784
});
9885
}
9986

@@ -128,11 +115,11 @@ export class ExploreVisualizationBuilder implements OnDestroy {
128115
private buildRequest(state: ExploreRequestState): ExploreVisualizationRequest {
129116
return {
130117
context: state.context,
118+
resultLimit: state.resultLimit,
131119
series: [...state.series],
132120
filters: state.filters && [...state.filters],
133121
interval: this.resolveInterval(state.interval),
134122
groupBy: state.groupBy && { ...state.groupBy },
135-
groupByLimit: state.groupByLimit,
136123
exploreQuery$: this.mapStateToExploreQuery(state),
137124
resultsQuery$: this.mapStateToResultsQuery(state)
138125
};
@@ -146,7 +133,7 @@ export class ExploreVisualizationBuilder implements OnDestroy {
146133
interval: this.resolveInterval(state.interval),
147134
filters: state.filters && this.graphQlFilterBuilderService.buildGraphQlFilters(state.filters),
148135
groupBy: state.groupBy,
149-
limit: state.groupByLimit === undefined ? ExploreVisualizationBuilder.DEFAULT_UNGROUPED_LIMIT : state.groupByLimit
136+
limit: state.resultLimit
150137
});
151138
}
152139

@@ -215,6 +202,7 @@ export class ExploreVisualizationBuilder implements OnDestroy {
215202
return {
216203
context: context,
217204
interval: 'AUTO',
205+
resultLimit: ExploreVisualizationBuilder.DEFAULT_LIMIT,
218206
series: [this.buildDefaultSeries(context)]
219207
};
220208
}
@@ -242,8 +230,8 @@ export interface ExploreRequestState {
242230
interval?: TimeDuration | 'AUTO';
243231
filters?: Filter[];
244232
groupBy?: GraphQlGroupBy;
245-
groupByLimit?: number;
246233
useGroupName?: boolean;
234+
resultLimit: number;
247235
}
248236

249237
export type ExploreRequestContext = TraceType | 'SPAN' | 'DOMAIN_EVENT';

projects/observability/src/shared/components/explore-query-editor/limit/explore-query-limit-editor.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
.limit-label {
1515
@include body-1-medium($gray-9);
16-
@include disableable;
1716
height: 32px;
1817
line-height: 32px;
1918
margin-bottom: 12px;

projects/observability/src/shared/components/explore-query-editor/limit/explore-query-limit-editor.component.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,6 @@ describe('Explore Query Limit Editor component', () => {
2626
expect(spectator.query(InputComponent)!.value).toBe(12);
2727
});
2828

29-
test('sets limit as disabled and display to Auto when disabled', () => {
30-
const spectator = hostBuilder(
31-
`
32-
<ht-explore-query-limit-editor [limit]="limit" [disabled]="disabled">
33-
</ht-explore-query-limit-editor>`,
34-
{
35-
hostProps: {
36-
limit: 12,
37-
disabled: true
38-
}
39-
}
40-
);
41-
42-
expect(spectator.query(InputComponent)!.value).toBe('Auto');
43-
expect(spectator.query(InputComponent)!.type).toBe('text');
44-
expect(spectator.query(InputComponent)!.disabled).toBe(true);
45-
expect(spectator.query('.limit-label')).toHaveClass('disabled');
46-
});
47-
4829
test('updates when the provided limit changes', () => {
4930
const spectator = hostBuilder(
5031
`

projects/observability/src/shared/components/explore-query-editor/limit/explore-query-limit-editor.component.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,21 @@ import { InputAppearance } from '@hypertrace/components';
88
template: `
99
<div class="limit-container">
1010
<div class="limit-number-input-container">
11-
<span class="limit-label" [ngClass]="{ disabled: this.disabled }"> Max Results </span>
11+
<span class="limit-label"> Max Groups </span>
1212
<div class="limit-input-wrapper">
1313
<ht-input
14-
[type]="this.getInputType()"
14+
type="number"
1515
class="limit-input"
1616
appearance="${InputAppearance.Border}"
17-
[disabled]="this.disabled"
18-
[value]="this.getLimitValue()"
17+
[value]="this.limit"
1918
(valueChange)="this.limitChange.emit($event)"
2019
>
2120
</ht-input>
2221
</div>
2322
</div>
24-
<div class="limit-include-rest-container" *ngIf="!this.disabled">
23+
<div class="limit-include-rest-container">
2524
<span class="limit-include-rest-label"> Show Other: </span>
26-
<ht-checkbox
27-
[disabled]="this.disabled"
28-
[checked]="this.includeRest"
29-
(checkedChange)="this.includeRestChange.emit($event)"
30-
>
31-
</ht-checkbox>
25+
<ht-checkbox [checked]="this.includeRest" (checkedChange)="this.includeRestChange.emit($event)"> </ht-checkbox>
3226
</div>
3327
</div>
3428
`
@@ -40,20 +34,9 @@ export class ExploreQueryLimitEditorComponent {
4034
@Input()
4135
public includeRest: boolean = false;
4236

43-
@Input()
44-
public disabled: boolean = false;
45-
4637
@Output()
4738
public readonly limitChange: EventEmitter<number> = new EventEmitter();
4839

4940
@Output()
5041
public readonly includeRestChange: EventEmitter<boolean> = new EventEmitter();
51-
52-
public getInputType(): string {
53-
return this.disabled ? 'text' : 'number';
54-
}
55-
56-
public getLimitValue(): string | number {
57-
return this.disabled ? 'Auto' : this.limit;
58-
}
5942
}

projects/observability/src/shared/dashboard/data/graphql/explore/explore-cartesian-data-source.model.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ describe('Explore cartesian data source model', () => {
150150

151151
model.groupBy = {
152152
keys: ['baz'],
153-
includeRest: true
153+
includeRest: true,
154+
limit: 5
154155
};
155156

156157
runFakeRxjs(({ expectObservable }) => {
@@ -212,7 +213,8 @@ describe('Explore cartesian data source model', () => {
212213
];
213214

214215
model.groupBy = {
215-
keys: ['baz']
216+
keys: ['baz'],
217+
limit: 5
216218
};
217219

218220
runFakeRxjs(({ expectObservable }) => {
@@ -316,7 +318,7 @@ export class TestExploreCartesianDataSourceModel extends ExploreCartesianDataSou
316318
public series?: ExploreSeries[];
317319
public context?: string = 'context_scope';
318320
public groupBy?: GraphQlGroupBy;
319-
public groupByLimit?: number;
321+
public resultLimit: number = 100;
320322

321323
protected buildRequestState(interval?: TimeDuration | 'AUTO'): ExploreRequestState | undefined {
322324
if ((this.series ?? [])?.length === 0 || this.context === undefined) {
@@ -328,7 +330,7 @@ export class TestExploreCartesianDataSourceModel extends ExploreCartesianDataSou
328330
context: this.context,
329331
interval: interval,
330332
groupBy: this.groupBy,
331-
groupByLimit: this.groupByLimit
333+
resultLimit: this.resultLimit
332334
};
333335
}
334336
}

0 commit comments

Comments
 (0)