Skip to content

Commit

Permalink
omniscient-logger: Populate data-lake with cockpit's memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Dec 6, 2024
1 parent bba019e commit c70b359
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/actions/data-lake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 19 additions & 0 deletions src/stores/omniscientLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down

0 comments on commit c70b359

Please sign in to comment.