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

omniscient-logger: Populate data-lake with Cockpit's memory usage #1477

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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