-
Notifications
You must be signed in to change notification settings - Fork 67
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
Changes from 46 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
b3972d0
commenting
mbarrramsey 760b5f9
commenting
mbarrramsey c57660e
.:
mbarrramsey b9537bd
.:
mbarrramsey cb47ee5
getting cost data
mbarrramsey 27a297d
adding recharts lib
mbarrramsey 361e1c2
adding custom colors to chart
mbarrramsey af30efb
chart working
mbarrramsey d339518
adding latency with recharts
mbarrramsey c8940d2
new packages
mbarrramsey 3098383
Merge branch 'master' of github.com:wandb/weave into mbarrramsey/trac…
mbarrramsey 3aae50c
added charts
mbarrramsey 0056b52
adding visx charts
mbarrramsey 3e55c47
fixing tooltip styling
mbarrramsey e0ea0b6
.
mbarrramsey d0885dd
switching back to plotly
mbarrramsey ae16f97
adding drawer
mbarrramsey 9485af6
adding padding
mbarrramsey 6c54311
.
mbarrramsey 7940de2
fast
mbarrramsey abc65bc
cleanup
mbarrramsey 5efc2cd
nit
mbarrramsey c62142d
linting
mbarrramsey 6f31e96
untouched files, reverting
mbarrramsey 7d0d9e1
lint
mbarrramsey f3ecefa
removing visx
mbarrramsey 1e97527
removing unused packages
mbarrramsey 9f6b521
removing react-plotly
mbarrramsey 8e7fa77
adding d3 types
mbarrramsey 9a37d11
.
mbarrramsey 17743b7
code cleanup
mbarrramsey c7e6382
.
mbarrramsey 9f8d248
Merge branch 'master' of github.com:wandb/weave into mbarrramsey/trac…
mbarrramsey 2c1d20c
lint
mbarrramsey 5b3f791
small pixel change to align insights
mbarrramsey f68eafb
code cleanup
mbarrramsey eb744ec
code cleanup
mbarrramsey 966bd46
cleanup
mbarrramsey d5e173d
linting
mbarrramsey 69d64a3
lint
mbarrramsey 1400ab4
fixing padding on insights
mbarrramsey 7fc4521
downgrading back to current plotly version
mbarrramsey ec462a7
.
mbarrramsey fed1e8b
d3
mbarrramsey 9595855
fixing mismatched padding
mbarrramsey 1898e27
.
mbarrramsey bb3c66c
linting
mbarrramsey 25c44dd
updating binning logic
mbarrramsey 69a9870
combining useCallsForQuery
mbarrramsey 61526f5
lint
mbarrramsey 47680f2
adding metrics toggle
mbarrramsey f03c547
adding loading state
mbarrramsey d3143bf
adding empty state
mbarrramsey 0f15609
linting
mbarrramsey 548146a
reverting old change
mbarrramsey e9f83ca
lint
mbarrramsey 355a757
switching to small toggle
mbarrramsey 2c8fb69
updating height to 250px and renaming constants in screaming case
mbarrramsey 423c4f0
.
mbarrramsey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
145 changes: 145 additions & 0 deletions
145
weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsCharts.tsx
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,145 @@ | ||
import {GridFilterModel, GridSortModel} from '@mui/x-data-grid-pro'; | ||
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 GitHub Actions / WeaveJS Lint and Compile
|
||
|
||
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'; | ||
import {fancyPageSidebarWidth} from '../../../../../../common/css/globals_deprecated.styles'; | ||
|
||
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, | ||
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> | ||
); | ||
}; |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
vs
10,000 points