Skip to content

Commit 94aa5f8

Browse files
authored
feat: Open span details panle in Service Health dashboard (#784)
1 parent 79fe30f commit 94aa5f8

File tree

1 file changed

+75
-45
lines changed

1 file changed

+75
-45
lines changed

packages/app/src/components/ServiceDashboardSlowestEventsTile.tsx

Lines changed: 75 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { useCallback } from 'react';
2+
import { parseAsString, useQueryState } from 'nuqs';
13
import { ClickHouseQueryError } from '@hyperdx/common-utils/dist/clickhouse';
24
import type { Filter, TSource } from '@hyperdx/common-utils/dist/types';
35
import { Box, Code, Group, Text } from '@mantine/core';
46

57
import { ChartBox } from '@/components/ChartBox';
8+
import DBRowSidePanel from '@/components/DBRowSidePanel';
69
import { DBSqlRowTable } from '@/components/DBRowTable';
710
import { useQueriedChartConfig } from '@/hooks/useChartConfig';
811
import { getExpressions } from '@/serviceDashboard';
12+
import { useSource } from '@/source';
913

1014
import { SQLPreview } from './ChartSQLPreview';
1115

@@ -28,6 +32,23 @@ export default function SlowestEventsTile({
2832
}) {
2933
const expressions = getExpressions(source);
3034

35+
const [rowId, setRowId] = useQueryState('rowId', parseAsString);
36+
const [rowSource, setRowSource] = useQueryState('rowSource', parseAsString);
37+
const { data: rowSidePanelSource } = useSource({ id: rowSource || '' });
38+
39+
const handleSidePanelClose = useCallback(() => {
40+
setRowId(null);
41+
setRowSource(null);
42+
}, [setRowId, setRowSource]);
43+
44+
const handleRowExpandClick = useCallback(
45+
(rowWhere: string) => {
46+
setRowId(rowWhere);
47+
setRowSource(source.id);
48+
},
49+
[source.id, setRowId, setRowSource],
50+
);
51+
3152
const { data, isLoading, isError, error } = useQueriedChartConfig(
3253
{
3354
...source,
@@ -102,51 +123,60 @@ export default function SlowestEventsTile({
102123
</div>
103124
) : (
104125
source && (
105-
<DBSqlRowTable
106-
config={{
107-
...source,
108-
where: '',
109-
whereLanguage: 'sql',
110-
select: [
111-
{
112-
valueExpression: source.timestampValueExpression,
113-
alias: 'Timestamp',
114-
},
115-
{
116-
valueExpression: expressions.severityText,
117-
alias: 'Severity',
118-
},
119-
{
120-
valueExpression: expressions.spanName,
121-
alias: 'Span Name',
122-
},
123-
{
124-
valueExpression: expressions.durationInMillis,
125-
alias: 'Duration (ms)',
126-
},
127-
],
128-
orderBy: [
129-
{
130-
valueExpression: expressions.durationInMillis,
131-
ordering: 'DESC',
132-
},
133-
],
134-
limit: { limit: 200 },
135-
dateRange,
136-
filters: [
137-
...extraFilters,
138-
{
139-
type: 'sql',
140-
condition: `${expressions.durationInMillis} > ${roundedP95}`,
141-
},
142-
],
143-
}}
144-
onRowExpandClick={() => {}}
145-
highlightedLineId={undefined}
146-
isLive={false}
147-
queryKeyPrefix="service-dashboard-slowest-transactions"
148-
onScroll={() => {}}
149-
/>
126+
<>
127+
<DBSqlRowTable
128+
config={{
129+
...source,
130+
where: '',
131+
whereLanguage: 'sql',
132+
select: [
133+
{
134+
valueExpression: source.timestampValueExpression,
135+
alias: 'Timestamp',
136+
},
137+
{
138+
valueExpression: expressions.severityText,
139+
alias: 'Severity',
140+
},
141+
{
142+
valueExpression: expressions.spanName,
143+
alias: 'Span Name',
144+
},
145+
{
146+
valueExpression: expressions.durationInMillis,
147+
alias: 'Duration (ms)',
148+
},
149+
],
150+
orderBy: [
151+
{
152+
valueExpression: expressions.durationInMillis,
153+
ordering: 'DESC',
154+
},
155+
],
156+
limit: { limit: 200 },
157+
dateRange,
158+
filters: [
159+
...extraFilters,
160+
{
161+
type: 'sql',
162+
condition: `${expressions.durationInMillis} > ${roundedP95}`,
163+
},
164+
],
165+
}}
166+
onRowExpandClick={handleRowExpandClick}
167+
highlightedLineId={rowId ?? undefined}
168+
isLive={false}
169+
queryKeyPrefix="service-dashboard-slowest-transactions"
170+
onScroll={() => {}}
171+
/>
172+
{rowId && rowSidePanelSource && (
173+
<DBRowSidePanel
174+
source={rowSidePanelSource}
175+
rowId={rowId}
176+
onClose={handleSidePanelClose}
177+
/>
178+
)}
179+
</>
150180
)
151181
)}
152182
</ChartBox>

0 commit comments

Comments
 (0)