-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<img width="1805" alt="image" src="https://github.com/hyperdxio/hyperdx/assets/2781687/94254c7c-b9a8-4a89-81f9-678394c1f157"> Also updates the db slowest query chart to be togglable between list bar chart and table chart <img width="1727" alt="image" src="https://github.com/hyperdxio/hyperdx/assets/2781687/73d2b458-65b9-47a5-976a-7f0db7a32d3d">
- Loading branch information
Showing
6 changed files
with
433 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import * as React from 'react'; | ||
import Drawer from 'react-modern-drawer'; | ||
import { StringParam, useQueryParam, withDefault } from 'use-query-params'; | ||
import { Box, Card, Grid, Text } from '@mantine/core'; | ||
|
||
import { | ||
convertDateRangeToGranularityString, | ||
INTEGER_NUMBER_FORMAT, | ||
MS_NUMBER_FORMAT, | ||
} from './ChartUtils'; | ||
import HDXMultiSeriesTimeChart from './HDXMultiSeriesTimeChart'; | ||
import SlowestEventsTile from './SlowestEventsTile'; | ||
import { parseTimeQuery, useTimeQuery } from './timeQuery'; | ||
import { useZIndex, ZIndexContext } from './zIndex'; | ||
|
||
import styles from '../styles/LogSidePanel.module.scss'; | ||
|
||
const defaultTimeRange = parseTimeQuery('Past 1h', false); | ||
|
||
const CHART_HEIGHT = 300; | ||
|
||
const DB_STATEMENT_PROPERTY = 'db.statement'; | ||
|
||
export default function DBQuerySidePanel() { | ||
const [service] = useQueryParam('service', withDefault(StringParam, ''), { | ||
updateType: 'replaceIn', | ||
}); | ||
|
||
const [dbQuery, setDbQuery] = useQueryParam( | ||
'db_query', | ||
withDefault(StringParam, ''), | ||
{ updateType: 'replaceIn' }, | ||
); | ||
|
||
const { searchedTimeRange: dateRange } = useTimeQuery({ | ||
isUTC: false, | ||
defaultValue: 'Past 1h', | ||
defaultTimeRange: [ | ||
defaultTimeRange?.[0]?.getTime() ?? -1, | ||
defaultTimeRange?.[1]?.getTime() ?? -1, | ||
], | ||
}); | ||
|
||
const scopeWhereQuery = React.useCallback( | ||
(where: string) => { | ||
const spanNameQuery = dbQuery | ||
? `${DB_STATEMENT_PROPERTY}:"${dbQuery}" ` | ||
: ''; | ||
const whereQuery = where ? `(${where})` : ''; | ||
const serviceQuery = service ? `service:"${service}" ` : ''; | ||
return `${spanNameQuery}${serviceQuery}${whereQuery}`.trim(); | ||
}, | ||
[dbQuery, service], | ||
); | ||
const contextZIndex = useZIndex(); | ||
const drawerZIndex = contextZIndex + 10; | ||
|
||
return ( | ||
<Drawer | ||
enableOverlay | ||
overlayOpacity={0.1} | ||
duration={0} | ||
open={!!dbQuery} | ||
onClose={() => { | ||
setDbQuery(undefined); | ||
}} | ||
direction="right" | ||
size={'80vw'} | ||
zIndex={drawerZIndex} | ||
> | ||
<ZIndexContext.Provider value={drawerZIndex}> | ||
<div className={styles.panel}> | ||
<Box p="md"> | ||
<Text size="md">Details for {dbQuery}</Text> | ||
</Box> | ||
<Box className="w-100 overflow-auto" px="sm"> | ||
<Grid> | ||
<Grid.Col span={6}> | ||
<Card p="md"> | ||
<Card.Section p="md" py="xs" withBorder> | ||
Total Query Time | ||
</Card.Section> | ||
<Card.Section p="md" py="sm" h={CHART_HEIGHT}> | ||
<HDXMultiSeriesTimeChart | ||
config={{ | ||
dateRange, | ||
granularity: convertDateRangeToGranularityString( | ||
dateRange, | ||
60, | ||
), | ||
series: [ | ||
{ | ||
displayName: 'Total Query Time', | ||
table: 'logs', | ||
type: 'time', | ||
aggFn: 'sum', | ||
field: 'duration', | ||
where: scopeWhereQuery(''), | ||
groupBy: [], | ||
numberFormat: MS_NUMBER_FORMAT, | ||
}, | ||
], | ||
seriesReturnType: 'column', | ||
}} | ||
/> | ||
</Card.Section> | ||
</Card> | ||
</Grid.Col> | ||
<Grid.Col span={6}> | ||
<Card p="md"> | ||
<Card.Section p="md" py="xs" withBorder> | ||
Query Throughput | ||
</Card.Section> | ||
<Card.Section p="md" py="sm" h={CHART_HEIGHT}> | ||
<HDXMultiSeriesTimeChart | ||
config={{ | ||
dateRange, | ||
granularity: convertDateRangeToGranularityString( | ||
dateRange, | ||
60, | ||
), | ||
series: [ | ||
{ | ||
displayName: 'Queries', | ||
table: 'logs', | ||
type: 'time', | ||
aggFn: 'count', | ||
where: scopeWhereQuery(''), | ||
groupBy: [], | ||
numberFormat: { | ||
...INTEGER_NUMBER_FORMAT, | ||
unit: 'queries', | ||
}, | ||
}, | ||
], | ||
seriesReturnType: 'column', | ||
}} | ||
/> | ||
</Card.Section> | ||
</Card> | ||
</Grid.Col> | ||
<Grid.Col span={12}> | ||
<SlowestEventsTile | ||
dateRange={dateRange} | ||
height={CHART_HEIGHT} | ||
scopeWhereQuery={scopeWhereQuery} | ||
title={<Text>Slowest 10% of Queries</Text>} | ||
/> | ||
</Grid.Col> | ||
</Grid> | ||
</Box> | ||
</div> | ||
</ZIndexContext.Provider> | ||
</Drawer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.