From 8f7410b8c273eca047b170e8dbb58802fd9cc031 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Fri, 22 Nov 2024 13:26:42 -0300 Subject: [PATCH] omniscient-logger: Populate data-lake with cockpit's memory usage --- src/libs/actions/data-lake.ts | 2 +- src/stores/omniscientLogger.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/data-lake.ts b/src/libs/actions/data-lake.ts index 6f71026b5..faa3072fe 100644 --- a/src/libs/actions/data-lake.ts +++ b/src/libs/actions/data-lake.ts @@ -5,7 +5,7 @@ * @param { 'string' | 'number' | 'boolean' } type - The type of the variable (string, number or boolean) * @param { string } description - What the variable does or means */ -class CockpitActionVariable { +export class CockpitActionVariable { id: string name: string type: 'string' | 'number' | 'boolean' diff --git a/src/stores/omniscientLogger.ts b/src/stores/omniscientLogger.ts index 399b5ea84..eb087cef4 100644 --- a/src/stores/omniscientLogger.ts +++ b/src/stores/omniscientLogger.ts @@ -3,6 +3,11 @@ import { useDocumentVisibility } from '@vueuse/core' import { defineStore } from 'pinia' import { ref, watch } from 'vue' +import { + CockpitActionVariable, + createCockpitActionVariable, + setCockpitActionVariableData, +} from '@/libs/actions/data-lake' import { WebRTCStatsEvent, WebRTCVideoStat } from '@/types/video' import { useVideoStore } from './video' @@ -12,6 +17,20 @@ export const webrtcStats = new WebRTCStats({ getStatsInterval: 250 }) export const useOmniscientLoggerStore = defineStore('omniscient-logger', () => { const videoStore = useVideoStore() + // Routine to log the memory usage of the application + const cockpitMemoryUsageVariable = new CockpitActionVariable( + 'cockpit-memory-usage', + 'Cockpit Memory Usage', + 'number', + 'The memory usage of the Cockpit application in MB. This value is updated every 100ms.' + ) + createCockpitActionVariable(cockpitMemoryUsageVariable) + + setInterval(() => { + const currentMemoryUsage = window.performance.memory.usedJSHeapSize / 1024 / 1024 + setCockpitActionVariableData(cockpitMemoryUsageVariable.id, currentMemoryUsage) + }, 100) + // Routine to log the framerate of the video streams const streamsFrameRateHistory = ref<{ [key in string]: number[] }>({}) let lastStreamAverageFramerateLog = new Date()