Skip to content

Commit 9f6a517

Browse files
committed
feat(cache-chart): Show hits/misses per poll interval
1 parent 70c2f8a commit 9f6a517

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

Diff for: spring-boot-admin-server-ui/src/main/frontend/views/instances/details/cache-chart.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default {
8585
const y = d3
8686
.scaleLinear()
8787
.range([this.height, 0])
88-
.domain([0, d3.max(data, (d) => d.total) * 1.05]);
88+
.domain([0, d3.max(data, (d) => d.totalPerInterval) * 1.05]);
8989

9090
//draw areas
9191
const miss = this.areas
@@ -101,8 +101,8 @@ export default {
101101
d3
102102
.area()
103103
.x((d) => x(d.timestamp))
104-
.y0((d) => y(d.hit))
105-
.y1((d) => y(d.total)),
104+
.y0((d) => y(d.hitsPerInterval))
105+
.y1((d) => y(d.totalPerInterval)),
106106
);
107107
miss.exit().remove();
108108

@@ -118,7 +118,7 @@ export default {
118118
.area()
119119
.x((d) => x(d.timestamp))
120120
.y0(y(0))
121-
.y1((d) => y(d.hit)),
121+
.y1((d) => y(d.hitsPerInterval)),
122122
);
123123
hit.exit().remove();
124124

Diff for: spring-boot-admin-server-ui/src/main/frontend/views/instances/details/details-cache.vue

+25-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
</template>
4444
<template v-if="ratio !== undefined">
4545
<dt
46-
class="sm:col-span-4"
46+
class="text-sm font-medium text-gray-500 sm:col-span-4"
4747
v-text="$t('instances.details.cache.hit_ratio')"
4848
/>
49-
<dd v-text="ratio" />
49+
<dd
50+
class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"
51+
v-text="ratio"
52+
/>
5053
</template>
5154
<template v-if="current.size !== undefined">
5255
<dt class="sm:col-span-4" v-text="$t('instances.details.cache.size')" />
@@ -91,7 +94,10 @@ export default {
9194
}),
9295
computed: {
9396
ratio() {
94-
if (Number.isFinite(this.current.hit) && Number.isFinite(this.current)) {
97+
if (
98+
Number.isFinite(this.current.hit) &&
99+
Number.isFinite(this.current.miss)
100+
) {
95101
const total = this.current.hit + this.current.miss;
96102
return total > 0
97103
? ((this.current.hit / total) * 100).toFixed(2) + '%'
@@ -179,7 +185,22 @@ export default {
179185
next: (data) => {
180186
this.hasLoaded = true;
181187
this.current = data;
182-
this.chartData.push({ ...data, timestamp: moment().valueOf() });
188+
let hitsPerInterval = 0;
189+
let missesPerInterval = 0;
190+
let totalPerInterval = 0;
191+
if (this.chartData.length > 0) {
192+
const lastChartData = this.chartData[this.chartData.length - 1];
193+
hitsPerInterval = data.hit - lastChartData.hit;
194+
missesPerInterval = data.miss - lastChartData.miss;
195+
totalPerInterval = data.total - lastChartData.total;
196+
}
197+
this.chartData.push({
198+
...data,
199+
timestamp: moment().valueOf(),
200+
hitsPerInterval,
201+
missesPerInterval,
202+
totalPerInterval,
203+
});
183204
},
184205
error: (error) => {
185206
this.hasLoaded = true;

0 commit comments

Comments
 (0)