Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
define fetch interval and max data points preferences
  • Loading branch information
V Udayani committed Nov 8, 2022
commit dcf55e6d542016efe2c73f309028842efe186ee6
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@
"update-tpn": "node scripts/update-third-party-notice.js"
},
"devDependencies": {
"@types/d3": "^7.1.0",
"@types/glob": "^7.2.0",
"@types/lodash": "^4.14.186",
"@types/mocha": "^9.1.1",
Expand Down
8 changes: 2 additions & 6 deletions resources/webview-ui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ window.addEventListener("load", main);

// Main function that gets executed once the webview DOM loads
function main() {

const graphTypeSelection = document.getElementById("graphType");
graphTypeSelection.addEventListener("change", changeGraphDisplay);

Expand All @@ -18,7 +19,6 @@ function main() {
});
}

// setInterval(refreshData, 5000);
loadMetrics();
setInterval(loadMetrics, interval);
setInterval(fetchGraphData, interval);
Expand All @@ -32,8 +32,6 @@ function loadMetrics() {
command: "LoadMetrics",
text: "Load metrics for the graph",
processKey: processKey,
// type: selection.value,
// tag: "area:heap"
});
}

Expand All @@ -48,8 +46,7 @@ function fetchGraphData() {
processKey: processKey,
type: graphType,
});
}

}
}

function changeGraphDisplay() {
Expand Down Expand Up @@ -327,7 +324,6 @@ function setGcPausesData(chart, dataPoints , type) {
}
chart.datasets[0].prevMeasurement = dataPoint;
chart.datasets[0].data.push(pt);
// data.labels.push(pt.time);
}
}
})
Expand Down
33 changes: 10 additions & 23 deletions src/views/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class MemoryProvider implements WebviewViewProvider{
private _view?: vscode.WebviewView;

private _extensionUrl: vscode.Uri;
private _interval: number= vscode.workspace.getConfiguration("spring.dashboard").get("memory-view.display-data.delay-in-milliseconds") ?? 5000;
private _maxDataPoints: number = vscode.workspace.getConfiguration("spring.dashboard").get("memory-view.display-data.max-datapoints") ?? 10;
private interval: number= vscode.workspace.getConfiguration("spring.dashboard").get("memory-view.fetch-data.delay-in-milliseconds") ?? 5000;
private maxDataPoints: number = vscode.workspace.getConfiguration("spring.dashboard").get("memory-view.display-data.max-datapoints") ?? 10;

constructor() {
vscode.commands.executeCommand("setContext", "spring.memoryGraphs:showMode", "defined");
Expand All @@ -62,22 +62,6 @@ class MemoryProvider implements WebviewViewProvider{
this._extensionUrl = value;
}

public get interval() {
return this._interval;
}

public set interval(value) {
this.interval = value;
}

public get maxDataPoints() {
return this._maxDataPoints;
}

public set maxDataPoints(value) {
this.maxDataPoints = value;
}

public resolveWebviewView(
webviewView: WebviewView,
_context: WebviewViewResolveContext,
Expand Down Expand Up @@ -127,6 +111,9 @@ class MemoryProvider implements WebviewViewProvider{
const chartjsAdapterScipt = getUri(webview, extensionUri, ["node_modules","chartjs-adapter-moment","dist","chartjs-adapter-moment.js"]);
const momentLibPath = getUri(webview, extensionUri, ["node_modules","moment","moment.js"]);

this.interval = vscode.workspace.getConfiguration("spring.dashboard").get("memory-view.fetch-data.delay-in-milliseconds") ?? 5000;
this.maxDataPoints = vscode.workspace.getConfiguration("spring.dashboard").get("memory-view.display-data.max-datapoints") ?? 10;

// Tip: Install the es6-string-html VS Code extension to enable code highlighting below
return /*html*/ `
<!DOCTYPE html>
Expand All @@ -142,8 +129,8 @@ class MemoryProvider implements WebviewViewProvider{
<script src="${chartjsAdapterPath}"></script>
<script src="${chartjsAdapterScipt}"></script>
<script src="${momentLibPath}"></script>
<script type="text/javascript"> var interval = ${this._interval}; </script>
<script type="text/javascript"> var maxDataPoints = ${this._maxDataPoints}; </script>
<script type="text/javascript"> var interval = ${this.interval}; </script>
<script type="text/javascript"> var maxDataPoints = ${this.maxDataPoints}; </script>
<link rel="stylesheet" href="${stylesUri}">
<title>Weather Checker</title>
</head>
Expand Down Expand Up @@ -269,7 +256,7 @@ class MemoryProvider implements WebviewViewProvider{
const metrics = this.storeGcPausesMetrics.get(targetLiveProcess);
if(metrics !== undefined) {
metrics.push(gcPausesMetrics);
const removeStaleData = metrics.length > this._maxDataPoints ? metrics?.shift() : undefined;
const removeStaleData = metrics.length > this.maxDataPoints ? metrics?.shift() : undefined;
}
}
}
Expand All @@ -294,7 +281,7 @@ class MemoryProvider implements WebviewViewProvider{
const metrics = this.storeHeapMemoryMetrics.get(targetLiveProcess);
if(metrics !== undefined) {
metrics?.push(memoryMetrics);
const removeStaleData = metrics.length > this._maxDataPoints ? metrics?.shift() : '';
const removeStaleData = metrics.length > this.maxDataPoints ? metrics?.shift() : '';
}
}
}
Expand All @@ -320,7 +307,7 @@ class MemoryProvider implements WebviewViewProvider{
const metrics = this.storeNonHeapMemoryMetrics.get(targetLiveProcess);
if(metrics !== undefined) {
metrics?.push(memoryMetrics);
const _removeStaleData = metrics.length > this._maxDataPoints ? metrics?.shift() : '';
const _removeStaleData = metrics.length > this.maxDataPoints ? metrics?.shift() : '';
}
}
}
Expand Down