Skip to content

Commit 1ff053d

Browse files
authored
feat(tracemetrics): Use new timeseries visualization (#105176)
Add the tracemetrics widgets to the new timeseries visualization allowlist. Also drop the timestamp transformation we're doing because it's not necessary any more for the new visualizations. Keeping it in messes up the timestamps on the chart and the release bubble querying.
1 parent f019636 commit 1ff053d

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

static/app/views/dashboards/datasetConfig/traceMetrics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export const TraceMetricsConfig: DatasetConfig<EventsTimeSeriesResponse, never>
182182
}
183183
return {
184184
data: timeSeries.values.map(value => ({
185-
name: value.timestamp / 1000, // Account for microseconds to milliseconds precision
185+
name: value.timestamp,
186186
value: value.value ?? 0,
187187
})),
188188
seriesName: formatTimeSeriesLabel(timeSeries),

static/app/views/dashboards/utils/widgetCanUseTimeSeriesVisualization.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ const SUPPORTED_WIDGET_TYPES = new Set<WidgetType>([
66
WidgetType.ISSUE,
77
WidgetType.LOGS,
88
WidgetType.ERRORS,
9-
// TODO(nar): Uncomment this to use new timeseries visualization, there is currently
10-
// a bug when adding a new y-axis in the widget builder to use this.
11-
// WidgetType.TRACEMETRICS,
9+
WidgetType.TRACEMETRICS,
1210
]);
1311

1412
const SUPPORTED_DISPLAY_TYPES = new Set<DisplayType>([

static/app/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState.spec.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,37 @@ describe('useWidgetBuilderState', () => {
16641664

16651665
expect(result.current.state.sort).toEqual([]);
16661666
});
1667+
1668+
it('updates the limit when the y-axis changes', () => {
1669+
mockedUsedLocation.mockReturnValue(
1670+
LocationFixture({
1671+
query: {
1672+
limit: '5',
1673+
field: ['event.type'],
1674+
yAxis: ['count()', 'count_unique(user)'],
1675+
},
1676+
})
1677+
);
1678+
const {result} = renderHook(() => useWidgetBuilderState(), {
1679+
wrapper: WidgetBuilderProvider,
1680+
});
1681+
1682+
expect(result.current.state.limit).toBe(5);
1683+
1684+
act(() => {
1685+
result.current.dispatch({
1686+
type: BuilderStateAction.SET_Y_AXIS,
1687+
payload: [
1688+
{function: ['count', '', undefined, undefined], kind: 'function'},
1689+
{function: ['count_unique', 'user', undefined, undefined], kind: 'function'},
1690+
{function: ['count_unique', 'title', undefined, undefined], kind: 'function'},
1691+
],
1692+
});
1693+
});
1694+
1695+
// The resulting limit should be at max 3
1696+
expect(result.current.state.limit).toBe(3);
1697+
});
16671698
});
16681699

16691700
describe('sort', () => {

static/app/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,15 @@ function useWidgetBuilderState(): {
562562
}
563563
case BuilderStateAction.SET_Y_AXIS:
564564
setYAxis(action.payload, options);
565+
566+
if (fields?.length && fields.length > 0) {
567+
// Check if we need to update the limit for a Top N query
568+
const maxLimit = getResultsLimit(query?.length ?? 1, action.payload.length);
569+
if (limit && limit > maxLimit) {
570+
setLimit(maxLimit, options);
571+
}
572+
}
573+
565574
if (action.payload.length > 0 && fields?.length === 0) {
566575
// Clear the sort if there is no grouping
567576
setSort([], options);

0 commit comments

Comments
 (0)