Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/olive-snails-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hyperdx/common-utils": minor
"@hyperdx/api": minor
"@hyperdx/app": minor
---

feat: Add materialized view support (Beta)
3 changes: 3 additions & 0 deletions packages/api/src/models/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const Source = mongoose.model<ISource>(
highlightedRowAttributeExpressions: {
type: mongoose.Schema.Types.Array,
},
materializedViews: {
type: mongoose.Schema.Types.Array,
},

metricTables: {
type: {
Expand Down
130 changes: 71 additions & 59 deletions packages/app/src/DBDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
} from '@/dashboard';

import DBSqlRowTableWithSideBar from './components/DBSqlRowTableWithSidebar';
import MVOptimizationIndicator from './components/MaterializedViews/MVOptimizationIndicator';
import OnboardingModal from './components/OnboardingModal';
import { Tags } from './components/Tags';
import useDashboardFilters from './hooks/useDashboardFilters';
Expand Down Expand Up @@ -256,66 +257,77 @@ const Tile = forwardRef(
<Text size="sm" ms="xs">
{chart.config.name}
</Text>
{hovered ? (
<Flex gap="0px">
{(chart.config.displayType === DisplayType.Line ||
chart.config.displayType === DisplayType.StackedBar) && (
<Indicator
size={alert?.state === AlertState.OK ? 6 : 8}
zIndex={1}
color={alertIndicatorColor}
processing={alert?.state === AlertState.ALERT}
label={!alert && <span className="fs-8">+</span>}
mr={4}
>
<Tooltip label={alertTooltip} withArrow>
<Button
data-testid={`tile-alerts-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onEditClick}
>
<IconBell size={16} />
</Button>
</Tooltip>
</Indicator>
)}
<Group>
{hovered ? (
<Flex gap="0px" onMouseDown={e => e.stopPropagation()}>
{(chart.config.displayType === DisplayType.Line ||
chart.config.displayType === DisplayType.StackedBar) && (
<Indicator
size={alert?.state === AlertState.OK ? 6 : 8}
zIndex={1}
color={alertIndicatorColor}
processing={alert?.state === AlertState.ALERT}
label={!alert && <span className="fs-8">+</span>}
mr={4}
>
<Tooltip label={alertTooltip} withArrow>
<Button
data-testid={`tile-alerts-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onEditClick}
>
<IconBell size={16} />
</Button>
</Tooltip>
</Indicator>
)}

<Button
data-testid={`tile-duplicate-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onDuplicateClick}
title="Duplicate"
>
<IconCopy size={14} />
</Button>
<Button
data-testid={`tile-edit-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onEditClick}
title="Edit"
>
<IconPencil size={14} />
</Button>
<Button
data-testid={`tile-delete-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onDeleteClick}
title="Delete"
>
<IconTrash size={14} />
</Button>
</Flex>
) : (
<Box h={22} />
)}
<Button
data-testid={`tile-duplicate-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onDuplicateClick}
title="Duplicate"
>
<IconCopy size={14} />
</Button>
<Button
data-testid={`tile-edit-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onEditClick}
title="Edit"
>
<IconPencil size={14} />
</Button>
<Button
data-testid={`tile-delete-button-${chart.id}`}
variant="subtle"
color="gray"
size="xxs"
onClick={onDeleteClick}
title="Delete"
>
<IconTrash size={14} />
</Button>
</Flex>
) : (
<Box h={22} />
)}
{source?.materializedViews?.length && queriedConfig && (
<Box onMouseDown={e => e.stopPropagation()}>
<MVOptimizationIndicator
config={queriedConfig}
source={source}
variant="icon"
/>
</Box>
)}
</Group>
</div>
<div
className="fs-7 text-muted flex-grow-1 overflow-hidden"
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ function useSearchedConfigToChartConfig({
data: {
select: select || (sourceObj.defaultTableSelectExpression ?? ''),
from: sourceObj.from,
source: sourceObj.id,
...(sourceObj.tableFilterExpression != null
? {
filters: [
Expand Down
21 changes: 20 additions & 1 deletion packages/app/src/ServicesDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function ServiceSelectControlled({
const { expressions } = useServiceDashboardExpressions({ source });

const queriedConfig = {
source: source?.id,
timestampValueExpression: source?.timestampValueExpression || '',
from: {
databaseName: source?.from.databaseName || '',
Expand Down Expand Up @@ -250,6 +251,7 @@ export function EndpointLatencyChart({
'avg_duration_ns',
]}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down Expand Up @@ -303,6 +305,7 @@ export function EndpointLatencyChart({
) : (
<DBHistogramChart
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand All @@ -311,9 +314,15 @@ export function EndpointLatencyChart({
where: appliedConfig.where || '',
whereLanguage: appliedConfig.whereLanguage || 'sql',
select: [
{
alias: 'data_nanoseconds',
aggFn: 'histogram',
level: 20,
valueExpression: expressions.duration,
},
{
alias: 'data',
valueExpression: `histogram(20)(${expressions.durationInMillis})`,
valueExpression: `arrayMap(bin -> (bin.1 / ${expressions.durationDivisorForMillis}, bin.2 / ${expressions.durationDivisorForMillis}, bin.3), data_nanoseconds)`,
},
],
filters: [
Expand Down Expand Up @@ -361,6 +370,7 @@ function HttpTab({
if (!source || !expressions) return null;
if (reqChartType === 'overall') {
return {
source: source.id,
...pick(source, ['timestampValueExpression', 'connection', 'from']),
where: appliedConfig.where || '',
whereLanguage: appliedConfig.whereLanguage || 'sql',
Expand Down Expand Up @@ -392,6 +402,7 @@ function HttpTab({
return {
timestampValueExpression: 'series_time_bucket',
connection: source.connection,
source: source.id,
with: [
{
name: 'error_series',
Expand Down Expand Up @@ -557,6 +568,7 @@ function HttpTab({
<DBTimeChart
sourceId={source.id}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down Expand Up @@ -601,6 +613,7 @@ function HttpTab({
'error_requests',
]}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down Expand Up @@ -726,6 +739,7 @@ function HttpTab({
'error_count',
]}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down Expand Up @@ -951,6 +965,7 @@ function DatabaseTab({
dateRange: searchedTimeRange,
timestampValueExpression: 'series_time_bucket',
connection: source.connection,
source: source.id,
} satisfies ChartConfigWithDateRange;
}, [appliedConfig, expressions, searchedTimeRange, source]);

Expand Down Expand Up @@ -1071,6 +1086,7 @@ function DatabaseTab({
dateRange: searchedTimeRange,
timestampValueExpression: 'series_time_bucket',
connection: source.connection,
source: source.id,
} satisfies ChartConfigWithDateRange;
}, [appliedConfig, expressions, searchedTimeRange, source]);

Expand Down Expand Up @@ -1149,6 +1165,7 @@ function DatabaseTab({
'p50_duration_ns',
]}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down Expand Up @@ -1229,6 +1246,7 @@ function DatabaseTab({
'p50_duration_ns',
]}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down Expand Up @@ -1327,6 +1345,7 @@ function ErrorsTab({
<DBTimeChart
sourceId={source.id}
config={{
source: source.id,
...pick(source, [
'timestampValueExpression',
'connection',
Expand Down
Loading
Loading