-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Endpoint dashboard, fix line chart colors, add search custom columns,…
… fix table column number format
- Loading branch information
Showing
9 changed files
with
488 additions
and
21 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
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,107 @@ | ||
import * as React from 'react'; | ||
import { Box, Button, Card, Flex } from '@mantine/core'; | ||
|
||
import { | ||
convertDateRangeToGranularityString, | ||
MS_NUMBER_FORMAT, | ||
} from './ChartUtils'; | ||
import HDXHistogramChart from './HDXHistogramChart'; | ||
import HDXMultiSeriesLineChart from './HDXMultiSeriesTimeChart'; | ||
import { Histogram } from './SVGIcons'; | ||
|
||
export default function EndpointLatencyTile({ | ||
height = 300, | ||
dateRange, | ||
scopeWhereQuery = (where: string) => where, | ||
}: { | ||
height?: number; | ||
dateRange: [Date, Date]; | ||
scopeWhereQuery?: (where: string) => string; | ||
}) { | ||
const [chartType, setChartType] = React.useState<'line' | 'histogram'>( | ||
'line', | ||
); | ||
|
||
return ( | ||
<Card p="md"> | ||
<Card.Section p="md" py="xs" withBorder> | ||
<Flex justify="space-between"> | ||
<span>Request Latency</span> | ||
<Box> | ||
<Button.Group> | ||
<Button | ||
variant="subtle" | ||
color={chartType === 'line' ? 'green' : 'dark.2'} | ||
size="xs" | ||
title="Line Chart" | ||
onClick={() => setChartType('line')} | ||
> | ||
<i className="bi bi-graph-up" /> | ||
</Button> | ||
|
||
<Button | ||
variant="subtle" | ||
color={chartType === 'histogram' ? 'green' : 'dark.2'} | ||
size="xs" | ||
title="Histogram" | ||
onClick={() => setChartType('histogram')} | ||
> | ||
<Histogram width={12} color="currentColor" /> | ||
</Button> | ||
</Button.Group> | ||
</Box> | ||
</Flex> | ||
</Card.Section> | ||
<Card.Section p="md" py="sm" h={height}> | ||
{chartType === 'line' ? ( | ||
<HDXMultiSeriesLineChart | ||
config={{ | ||
dateRange, | ||
granularity: convertDateRangeToGranularityString(dateRange, 60), | ||
series: [ | ||
{ | ||
displayName: '95th Percentile', | ||
table: 'logs', | ||
type: 'time', | ||
aggFn: 'p95', | ||
field: 'duration', | ||
where: scopeWhereQuery('span.kind:"server"'), | ||
groupBy: [], | ||
numberFormat: MS_NUMBER_FORMAT, | ||
}, | ||
{ | ||
displayName: 'Median', | ||
table: 'logs', | ||
type: 'time', | ||
aggFn: 'p50', | ||
field: 'duration', | ||
where: scopeWhereQuery('span.kind:"server"'), | ||
groupBy: [], | ||
}, | ||
{ | ||
displayName: 'Average', | ||
table: 'logs', | ||
type: 'time', | ||
aggFn: 'avg', | ||
field: 'duration', | ||
where: scopeWhereQuery('span.kind:"server"'), | ||
groupBy: [], | ||
}, | ||
], | ||
seriesReturnType: 'column', | ||
}} | ||
/> | ||
) : ( | ||
<HDXHistogramChart | ||
config={{ | ||
table: 'logs', | ||
field: 'duration', | ||
where: scopeWhereQuery('span.kind:"server"'), | ||
dateRange, | ||
}} | ||
/> | ||
)} | ||
</Card.Section> | ||
</Card> | ||
); | ||
} |
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,103 @@ | ||
import { memo } from 'react'; | ||
import { Box, Flex, Text } from '@mantine/core'; | ||
|
||
import api from './api'; | ||
import { Granularity } from './ChartUtils'; | ||
import type { ChartSeries, NumberFormat } from './types'; | ||
import { semanticKeyedColor } from './utils'; | ||
|
||
function ListItem({ | ||
title, | ||
value, | ||
color, | ||
percent, | ||
}: { | ||
title: string; | ||
value: string; | ||
color: string; | ||
percent: number; | ||
}) { | ||
return ( | ||
<Box> | ||
<Flex justify="space-between"> | ||
<Text size="sm">{title}</Text> | ||
<Text size="sm">{value}</Text> | ||
</Flex> | ||
<Box pt="xs"> | ||
<Box | ||
style={{ | ||
width: `${percent}%`, | ||
height: 8, | ||
backgroundColor: color, | ||
borderRadius: 4, | ||
}} | ||
/> | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
const HDXListBarChart = memo( | ||
({ | ||
config: { series, seriesReturnType = 'column', dateRange }, | ||
}: { | ||
config: { | ||
series: [ChartSeries]; | ||
granularity: Granularity; | ||
dateRange: [Date, Date]; | ||
seriesReturnType?: 'ratio' | 'column'; | ||
numberFormat?: NumberFormat; | ||
groupColumnName?: string; | ||
}; | ||
onSettled?: () => void; | ||
}) => { | ||
const { data, isError, isLoading } = api.useMultiSeriesChart({ | ||
series, | ||
endDate: dateRange[1] ?? new Date(), | ||
startDate: dateRange[0] ?? new Date(), | ||
seriesReturnType, | ||
}); | ||
|
||
const rows: undefined | any[] = data?.data; | ||
|
||
const values = (rows ?? []).map((row: any) => row['series_0.data']); | ||
const maxValue = Math.max(...values); | ||
const totalValue = values.reduce((a, b) => a + b, 0); | ||
|
||
return isLoading ? ( | ||
<div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
Loading Chart Data... | ||
</div> | ||
) : isError ? ( | ||
<div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
Error loading chart, please try again or contact support. | ||
</div> | ||
) : data?.data?.length === 0 ? ( | ||
<div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
No data found within time range. | ||
</div> | ||
) : ( | ||
<Box className="overflow-auto" h="100%"> | ||
{rows?.map((row: any) => { | ||
const value = row['series_0.data']; | ||
const percentOfMax = (value / maxValue) * 100; | ||
const percentOfTotal = (value / totalValue) * 100; | ||
const group = `${row.group}`; | ||
|
||
return ( | ||
<Box mb="sm" key={group}> | ||
<ListItem | ||
title={group} | ||
value={`${percentOfTotal.toFixed(2)}%`} | ||
color={semanticKeyedColor(group)} | ||
percent={percentOfMax} | ||
/> | ||
</Box> | ||
); | ||
})} | ||
</Box> | ||
); | ||
}, | ||
); | ||
|
||
export default HDXListBarChart; |
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
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
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.