Skip to content

Commit dac731f

Browse files
committed
fix: cache details panel
1 parent 7746d41 commit dac731f

File tree

6 files changed

+212
-111
lines changed

6 files changed

+212
-111
lines changed

spring-boot-admin-server-ui/package-lock.json

Lines changed: 48 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spring-boot-admin-server-ui/src/main/frontend/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ sbaConfig.extensions.css.forEach((extension) => {
7676
moment.locale(navigator.language.split('-')[0]);
7777

7878
if (process.env.NODE_ENV === 'development') {
79-
worker.start({
80-
serviceWorker: {
81-
url: './mockServiceWorker.js',
82-
},
83-
});
79+
await worker.start();
8480
}
8581

8682
const installables = [Notifications, ...views];

spring-boot-admin-server-ui/src/main/frontend/mocks/browser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import auditEventsEndpoint from './instance/auditevents/index.js';
44
import flywayEndpoints from './instance/flyway/index.js';
55
import liquibaseEndpoints from './instance/liquibase/index.js';
66
import mappingsEndpoint from './instance/mappings/index.js';
7+
import metricsEndpoint from './instance/metrics/index.js';
78

89
const handler = [
910
...mappingsEndpoint,
1011
...liquibaseEndpoints,
1112
...flywayEndpoints,
1213
...auditEventsEndpoint,
14+
...metricsEndpoint,
1315
];
1416

1517
export const worker = setupWorker(...handler);

spring-boot-admin-server-ui/src/main/frontend/mocks/instance/metrics/index.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,114 @@ const metricsEntpoints = [
1919
return HttpResponse.json(memoryCommittedResponse);
2020
},
2121
),
22+
http.get('/instances/:instanceId/actuator/metrics', () => {
23+
return HttpResponse.json({
24+
names: ['cache.gets', 'jdbc.connections.active'],
25+
});
26+
}),
27+
http.get('/instances/:instanceId/actuator/metrics/cache.gets', () => {
28+
return HttpResponse.json({
29+
name: 'cache.gets',
30+
description: 'The number of cache gets',
31+
baseUnit: 'none',
32+
measurements: [
33+
{
34+
statistic: 'COUNT',
35+
value: 150,
36+
},
37+
{
38+
statistic: 'TOTAL_TIME',
39+
value: 120.5,
40+
},
41+
{
42+
statistic: 'MAX',
43+
value: 5.2,
44+
},
45+
],
46+
availableTags: [
47+
{
48+
tag: 'name',
49+
values: ['myCache'],
50+
},
51+
{
52+
tag: 'cache',
53+
values: ['myCache'],
54+
},
55+
{
56+
tag: 'result',
57+
values: ['hit', 'miss'],
58+
},
59+
],
60+
});
61+
}),
62+
http.get(
63+
'/instances/:instanceId/actuator/metrics/jdbc.connections.active',
64+
() => {
65+
return HttpResponse.json({
66+
name: 'jdbc.connections.active',
67+
description: 'The number of active JDBC connections',
68+
baseUnit: 'connections',
69+
measurements: [
70+
{
71+
statistic: 'VALUE',
72+
value: 5,
73+
},
74+
],
75+
availableTags: [
76+
{
77+
tag: 'name',
78+
values: ['HikariPool-1'],
79+
},
80+
{
81+
tag: 'pool',
82+
values: ['HikariPool-1'],
83+
},
84+
{
85+
tag: 'min',
86+
values: 1,
87+
},
88+
],
89+
});
90+
},
91+
),
92+
http.get('/instances/:instanceId/actuator/metrics/jdbc.connections.min', () =>
93+
HttpResponse.json({
94+
name: 'jdbc.connections.min',
95+
description: 'The minimum number of idle JDBC connections in the pool',
96+
baseUnit: 'connections',
97+
measurements: [
98+
{
99+
statistic: 'VALUE',
100+
value: 10,
101+
},
102+
],
103+
availableTags: [
104+
{
105+
tag: 'pool',
106+
values: ['HikariPool-1'],
107+
},
108+
],
109+
}),
110+
),
111+
http.get('/instances/:instanceId/actuator/metrics/jdbc.connections.max', () =>
112+
HttpResponse.json({
113+
name: 'jdbc.connections.max',
114+
description: 'The minimum number of idle JDBC connections in the pool',
115+
baseUnit: 'connections',
116+
measurements: [
117+
{
118+
statistic: 'VALUE',
119+
value: 10,
120+
},
121+
],
122+
availableTags: [
123+
{
124+
tag: 'pool',
125+
values: ['HikariPool-1'],
126+
},
127+
],
128+
}),
129+
),
22130
];
23131

24132
export default metricsEntpoints;

spring-boot-admin-server-ui/src/main/frontend/public/mockServiceWorker.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* - Please do NOT serve this file on production.
99
*/
1010

11-
const PACKAGE_VERSION = '2.6.4'
12-
const INTEGRITY_CHECKSUM = 'ca7800994cc8bfb5eb961e037c877074'
11+
const PACKAGE_VERSION = '2.7.3'
12+
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
1313
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
1414
const activeClientIds = new Set()
1515

@@ -199,7 +199,19 @@ async function getResponse(event, client, requestId) {
199199
// Remove the "accept" header value that marked this request as passthrough.
200200
// This prevents request alteration and also keeps it compliant with the
201201
// user-defined CORS policies.
202-
headers.delete('accept', 'msw/passthrough')
202+
const acceptHeader = headers.get('accept')
203+
if (acceptHeader) {
204+
const values = acceptHeader.split(',').map((value) => value.trim())
205+
const filteredValues = values.filter(
206+
(value) => value !== 'msw/passthrough',
207+
)
208+
209+
if (filteredValues.length > 0) {
210+
headers.set('accept', filteredValues.join(', '))
211+
} else {
212+
headers.delete('accept')
213+
}
214+
}
203215

204216
return fetch(requestClone, { headers })
205217
}

0 commit comments

Comments
 (0)