Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(weave): adding charts to the traces page #2745

Merged
merged 59 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b3972d0
commenting
mbarrramsey Oct 21, 2024
760b5f9
commenting
mbarrramsey Oct 21, 2024
c57660e
.:
mbarrramsey Oct 22, 2024
b9537bd
.:
mbarrramsey Oct 22, 2024
cb47ee5
getting cost data
mbarrramsey Oct 22, 2024
27a297d
adding recharts lib
mbarrramsey Oct 23, 2024
361e1c2
adding custom colors to chart
mbarrramsey Oct 23, 2024
af30efb
chart working
mbarrramsey Oct 23, 2024
d339518
adding latency with recharts
mbarrramsey Oct 23, 2024
c8940d2
new packages
mbarrramsey Oct 23, 2024
3098383
Merge branch 'master' of github.com:wandb/weave into mbarrramsey/trac…
mbarrramsey Oct 23, 2024
3aae50c
added charts
mbarrramsey Oct 24, 2024
0056b52
adding visx charts
mbarrramsey Oct 24, 2024
3e55c47
fixing tooltip styling
mbarrramsey Oct 24, 2024
e0ea0b6
.
mbarrramsey Oct 24, 2024
d0885dd
switching back to plotly
mbarrramsey Oct 24, 2024
ae16f97
adding drawer
mbarrramsey Oct 24, 2024
9485af6
adding padding
mbarrramsey Oct 24, 2024
6c54311
.
mbarrramsey Oct 24, 2024
7940de2
fast
mbarrramsey Oct 25, 2024
abc65bc
cleanup
mbarrramsey Oct 25, 2024
5efc2cd
nit
mbarrramsey Oct 25, 2024
c62142d
linting
mbarrramsey Oct 25, 2024
6f31e96
untouched files, reverting
mbarrramsey Oct 25, 2024
7d0d9e1
lint
mbarrramsey Oct 25, 2024
f3ecefa
removing visx
mbarrramsey Oct 25, 2024
1e97527
removing unused packages
mbarrramsey Oct 25, 2024
9f6b521
removing react-plotly
mbarrramsey Oct 25, 2024
8e7fa77
adding d3 types
mbarrramsey Oct 25, 2024
9a37d11
.
mbarrramsey Oct 25, 2024
17743b7
code cleanup
mbarrramsey Oct 25, 2024
c7e6382
.
mbarrramsey Oct 25, 2024
9f8d248
Merge branch 'master' of github.com:wandb/weave into mbarrramsey/trac…
mbarrramsey Oct 25, 2024
2c1d20c
lint
mbarrramsey Oct 25, 2024
5b3f791
small pixel change to align insights
mbarrramsey Oct 25, 2024
f68eafb
code cleanup
mbarrramsey Oct 28, 2024
eb744ec
code cleanup
mbarrramsey Oct 28, 2024
966bd46
cleanup
mbarrramsey Oct 28, 2024
d5e173d
linting
mbarrramsey Oct 28, 2024
69d64a3
lint
mbarrramsey Oct 28, 2024
1400ab4
fixing padding on insights
mbarrramsey Oct 28, 2024
7fc4521
downgrading back to current plotly version
mbarrramsey Oct 28, 2024
ec462a7
.
mbarrramsey Oct 28, 2024
fed1e8b
d3
mbarrramsey Oct 28, 2024
9595855
fixing mismatched padding
mbarrramsey Oct 29, 2024
1898e27
.
mbarrramsey Oct 29, 2024
bb3c66c
linting
mbarrramsey Oct 29, 2024
25c44dd
updating binning logic
mbarrramsey Oct 29, 2024
69a9870
combining useCallsForQuery
mbarrramsey Oct 29, 2024
61526f5
lint
mbarrramsey Oct 29, 2024
47680f2
adding metrics toggle
mbarrramsey Oct 29, 2024
f03c547
adding loading state
mbarrramsey Oct 29, 2024
d3143bf
adding empty state
mbarrramsey Oct 29, 2024
0f15609
linting
mbarrramsey Oct 29, 2024
548146a
reverting old change
mbarrramsey Oct 29, 2024
e9f83ca
lint
mbarrramsey Oct 29, 2024
355a757
switching to small toggle
mbarrramsey Oct 29, 2024
2c8fb69
updating height to 250px and renaming constants in screaming case
mbarrramsey Oct 29, 2024
423c4f0
.
mbarrramsey Oct 29, 2024
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
1 change: 1 addition & 0 deletions weave-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"@types/color": "^3.0.0",
"@types/cytoscape": "^3.2.0",
"@types/cytoscape-dagre": "^2.2.2",
"@types/d3-array": "^3.2.1",
"@types/diff": "^5.0.3",
"@types/downloadjs": "^1.4.2",
"@types/is-buffer": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import {GridFilterModel, GridSortModel} from '@mui/x-data-grid-pro';

Check warning on line 1 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsCharts.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

Run autofix to sort these imports!
import React, {useEffect, useMemo, useRef, useState} from 'react';

Check warning on line 2 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsCharts.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'useEffect' is defined but never used

Check warning on line 2 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsCharts.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'useRef' is defined but never used

import {
IconChevronDown,
IconChevronNext,
IconLightbulbInfo,
} from '../../../../../Icon';
import {Tailwind} from '../../../../../Tailwind';
import {WFHighLevelCallFilter} from './callsTableFilter';
import {useCallsForQueryCharts} from './callsTableQuery';
import {
ErrorPlotlyChart,
LatencyPlotlyChart,
RequestsPlotlyChart,
} from './Charts';
import {Box} from '@mui/material';

Check warning on line 17 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsCharts.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'Box' is defined but never used
import {fancyPageSidebarWidth} from '../../../../../../common/css/globals_deprecated.styles';

Check warning on line 18 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsCharts.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'fancyPageSidebarWidth' is defined but never used

type CallsChartsProps = {
entity: string;
project: string;
filterModelProp: GridFilterModel;
filter: WFHighLevelCallFilter;
};

export const CallsCharts = ({
entity,
project,
filter,
filterModelProp,
}: CallsChartsProps) => {
const columns = useMemo(
() => ['started_at', 'ended_at', 'exception', 'id'],
[]
);
const columnSet = useMemo(() => new Set(columns), [columns]);
const sortCalls: GridSortModel = useMemo(
() => [{field: 'started_at', sort: 'desc'}],
[]
);
const calls = useCallsForQueryCharts(
entity,
project,
filter,
filterModelProp,
0,
1000,
Copy link
Contributor Author

@mbarrramsey mbarrramsey Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can update to 10,000 or any arbitrary number

1,000 points

Screenshot 2024-10-28 at 10 35 53 AM

vs

10,000 points
Screenshot 2024-10-28 at 10 35 16 AM

columns,
columnSet,
sortCalls
);
const [isInsightsOpen, setIsInsightsOpen] = useState(false);

const toggleInsights = () => {
setIsInsightsOpen(!isInsightsOpen);
};

const chartData = useMemo(() => {
if (calls.loading || !calls.result || calls.result.length === 0) {
return {latency: [], errors: [], requests: []};
}

const data: {
latency: Array<{started_at: string; latency: number}>;
errors: Array<{started_at: string; isError: boolean}>;
requests: Array<{started_at: string}>;
} = {
latency: [],
errors: [],
requests: [],
};

calls.result.forEach(call => {
const started_at = call.traceCall?.started_at;
if (!started_at) {
return;
}
const ended_at = call.traceCall?.ended_at;

const isError =
call.traceCall?.exception !== null &&
call.traceCall?.exception !== undefined &&
call.traceCall?.exception !== '';

data.requests.push({started_at});

if (isError) {
data.errors.push({started_at, isError});
} else {
data.errors.push({started_at, isError: false});
}

if (ended_at !== undefined) {
const startTime = new Date(started_at).getTime();
const endTime = new Date(ended_at).getTime();
const latency = endTime - startTime;
data.latency.push({started_at, latency});
}
});
return data;
}, [calls.result, calls.loading]);

const chartWrapper = 'flex-1 rounded-lg border border-moon-250 bg-white p-10';

const charts = (
<div className="m-10 flex flex-row gap-10">
<div className={chartWrapper}>
<LatencyPlotlyChart chartData={chartData.latency} height={300} />
</div>
<div className={chartWrapper}>
<ErrorPlotlyChart chartData={chartData.errors} height={300} />
</div>
<div className={chartWrapper}>
<RequestsPlotlyChart chartData={chartData.requests} height={300} />
</div>
</div>
);

return (
<Tailwind>
{/* setting the width to the width of the screen minus the sidebar width because of overflow: 'hidden' properties in SimplePageLayout causing issues */}
<div className="md:w-[calc(100vw-56px)]">
<div className="m-10">
<div className="w-full rounded-lg border border-moon-250 bg-moon-50 p-10">
<div
className="flex cursor-pointer items-center gap-2"
onClick={toggleInsights}>
{isInsightsOpen ? <IconChevronDown /> : <IconChevronNext />}
<IconLightbulbInfo
width={18}
height={18}
className="text-teal-500"
/>
<div className="font-source-sans-pro mt-[1px] text-[18px] font-semibold text-moon-500">
Insights
</div>
</div>
{isInsightsOpen && charts}
</div>
</div>
</div>
</Tailwind>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import {traceCallToUICallSchema} from '../wfReactInterface/tsDataModelHooks';
import {EXPANDED_REF_REF_KEY} from '../wfReactInterface/tsDataModelHooksCallRefExpansion';
import {objectVersionNiceString} from '../wfReactInterface/utilities';
import {CallSchema} from '../wfReactInterface/wfDataModelHooksInterface';
import {CallsCharts} from './CallsCharts';
import {CallsCustomColumnMenu} from './CallsCustomColumnMenu';
import {
BulkDeleteButton,
Expand Down Expand Up @@ -849,6 +850,12 @@ export const CallsTable: FC<{
)}
</TailwindContents>
}>
<CallsCharts
entity={entity}
project={project}
filter={filter}
filterModelProp={filterModelResolved}
/>
<StyledDataGrid
// Start Column Menu
// ColumnMenu is needed to support pinning and column visibility
Expand Down
Loading
Loading