Files
windmill/frontend/src/lib/components/MemoryFootprintViewer.svelte
T
310f37a682 feat: migrate to svelte5 + vite6 (#4813)
* runs on svelte 5

* Line component from svelte-chartjs

* Replaced all svelte-chartjs occurrences with custom wrapper

* Fix props mistake

* Fix illegal table structures

* self-closing-tags fix

* aria labels

* Fixed trivial warnings and errors

* @tanstack/svelte-table fix

* upgrade to vite 6

* svelte-kit sync before running svelte-check

* Remove on:clear which is actually on:removeAll and already handled by on:change

* fix worker tags not displaying in Autoscaling

* Try to fix svelte-kit sync not working during CI

* remove warnings

* Fix add flow page crashing

* access worldStore before assignment fix

* fix infinite recursions in App Editor

* Replaced JSON.stringify with proper deepEqual

* component mount api changed (no longer classes)

* fix ci errors

* Fix infinite loops in background runnable panel

* factored effect on deep equal logic in onObjChange

* fix "Add" not working in AgGrid Table

* Replaced legacy component.$set api

* Fix multiselect infinite value reaction

* Fix flow input fields resetting when opening their edit tab

* fix date input resetting when typing year

* Remove !p-0 affecting subgrid dotted borders

* fix missing debounceTemplate causing hundreds of updates

* Fix AgGrid action refreshes and disppearing

* resolve getItems generating random ids every rerun

* fix cannot access items before init

* fix sort lambda arguments being undefined

* Revert "Remove !p-0 affecting subgrid dotted borders"

This reverts commit c62809bb45d682a48376b071680645ed4e1c601b.

* fix input not updating in decision tree editor

* Update frontend/src/lib/components/schema/EditableSchemaWrapper.svelte

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Re-added padding affecting subgrid dotted borders (#5479)

* remove !p-0 in preset components

* removed extra padding on accordion tabs subgrid

* Fix non-reactive SchemaForm

* dirty fix for the oneOf bug

* Fix warnings and update svelte-exmarkdown for svelte 5

* fix dnd not working

* don't mount component like objects

---------

Co-authored-by: Diego Imbert <diegoimbert@protonmail.com>
Co-authored-by: Diego Imbert <70353967+diegoimbert@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-04-02 21:33:50 +00:00

108 lines
2.6 KiB
Svelte

<script lang="ts">
import { type MetricDataPoint, MetricsService } from '$lib/gen'
import { displayTime } from '$lib/utils'
import { enterpriseLicense, workspaceStore } from '$lib/stores'
import {
CategoryScale,
Chart as ChartJS,
Legend,
LinearScale,
LineElement,
PointElement,
Title,
Tooltip
} from 'chart.js'
import { Line } from '$lib/components/chartjs-wrappers/chartJs'
import { Alert } from './common'
ChartJS.register(Title, Tooltip, Legend, LineElement, LinearScale, PointElement, CategoryScale)
export let jobId: string
export let jobUpdateLastFetch: Date | undefined
let jobMetricsLastFetch: Date | undefined = undefined
let jobMemoryStats: MetricDataPoint[] | undefined = undefined
let data: {
x: number
y: number
}[] = []
let labels: string[] = []
async function loadMetricsData() {
try {
let jobStatsPromise = MetricsService.getJobMetrics({
workspace: $workspaceStore!,
id: jobId,
requestBody: {
from_timestamp: jobMetricsLastFetch?.toISOString(),
timeseries_max_datapoints: 0
}
})
jobMetricsLastFetch = new Date()
let jobStats = await jobStatsPromise
let memoryTimeseries =
jobStats.timeseries_metrics?.filter((ts) => ts.metric_id === 'memory_kb') ?? []
if (memoryTimeseries.length > 0) {
jobMemoryStats = (jobMemoryStats ?? []).concat(memoryTimeseries[0].values)
}
} catch {
console.error('Unable to load metrics data for job', jobId)
return
}
for (let dp of jobMemoryStats ?? []) {
let ts = new Date(dp.timestamp).valueOf()
if (data.length === 0 || ts > data[data.length - 1].x) {
data.push({
x: ts,
y: dp.value
})
labels.push(displayTime(dp.timestamp))
}
}
data = [...data]
}
$: jobUpdateLastFetch && loadMetricsData()
</script>
<div class="relative max-h-100">
{#if !$enterpriseLicense}
<Alert type="error" title="Enterprise Edition only feature">
Job metrics are only available on Windmill Enterprise Edition.
</Alert>
{:else if (jobMemoryStats?.length ?? 0) === 0}
<Alert type="info" title="No metric available"
>No data points available for this job. Metrics are recorded only for jobs running for more
than 500ms.</Alert
>
{/if}
<Line
class="w-full max-h-80"
data={{
labels: labels,
datasets: [
{
label: 'Job memory footprint (kB)',
data: data,
fill: false,
borderColor: 'rgb(59, 130, 246, 0.8)',
backgroundColor: 'rgb(59, 130, 246, 0.8)',
tension: 0.1
}
]
}}
options={{
animation: {
duration: 0
},
maintainAspectRatio: false,
responsive: true
}}
/>
</div>