@antelopejs/dms-api 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/frontend-module.d.ts +2 -0
- package/dist/frontend-module.js +17 -0
- package/dist/frontend-module.js.map +1 -0
- package/dist/index.js +2 -8
- package/dist/index.js.map +1 -1
- package/dist/pages/logs.d.ts +1 -1
- package/dist/pages/logs.js +3 -4
- package/dist/pages/logs.js.map +1 -1
- package/dist/pages/overview.d.ts +1 -1
- package/dist/pages/overview.js +13 -12
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/request-table.js +13 -9
- package/dist/pages/request-table.js.map +1 -1
- package/dist/pages/routes.d.ts +1 -1
- package/dist/pages/routes.js +12 -11
- package/dist/pages/routes.js.map +1 -1
- package/dist/pages/toolbar.d.ts +6 -5
- package/dist/pages/toolbar.js +26 -19
- package/dist/pages/toolbar.js.map +1 -1
- package/dist/routes/logs.d.ts +10 -1
- package/dist/routes/logs.js +10 -3
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/overview.d.ts +2 -2
- package/dist/routes/overview.js +3 -2
- package/dist/routes/overview.js.map +1 -1
- package/dist/services/comparison.d.ts +16 -0
- package/dist/services/comparison.js +66 -0
- package/dist/services/comparison.js.map +1 -0
- package/dist/services/live.d.ts +19 -3
- package/dist/services/live.js +104 -17
- package/dist/services/live.js.map +1 -1
- package/dist/services/overview-lists.d.ts +25 -0
- package/dist/services/overview-lists.js +119 -0
- package/dist/services/overview-lists.js.map +1 -0
- package/dist/services/overview.d.ts +7 -22
- package/dist/services/overview.js +18 -92
- package/dist/services/overview.js.map +1 -1
- package/dist/services/route-statistics.d.ts +4 -0
- package/dist/services/route-statistics.js +101 -39
- package/dist/services/route-statistics.js.map +1 -1
- package/dist/services/settings-form.js +4 -1
- package/dist/services/settings-form.js.map +1 -1
- package/dist/services/traffic.d.ts +8 -0
- package/dist/services/traffic.js +77 -0
- package/dist/services/traffic.js.map +1 -1
- package/dist/services/window.d.ts +6 -0
- package/dist/services/window.js +32 -9
- package/dist/services/window.js.map +1 -1
- package/frontend-vue/app/components/blocks/HealthHero.vue +23 -13
- package/frontend-vue/app/components/blocks/LiveTraffic.vue +165 -38
- package/frontend-vue/app/components/blocks/LogsFilters.vue +1 -1
- package/frontend-vue/app/components/blocks/RequestDetail.vue +43 -37
- package/frontend-vue/app/components/blocks/RouteHeader.vue +35 -15
- package/frontend-vue/app/components/blocks/RouteTree.vue +7 -8
- package/frontend-vue/app/composables/useLastRoute.ts +16 -0
- package/frontend-vue/app/middleware/defaultRoute.ts +31 -0
- package/frontend-vue/app/utils/format.ts +9 -0
- package/frontend-vue/app/utils/minuteHistogram.ts +51 -16
- package/frontend-vue/app/utils/routeExplorer.ts +23 -15
- package/frontend-vue/dms.frontend.ts +5 -0
- package/frontend-vue/i18n/locales/api-en-GB.json +41 -12
- package/frontend-vue/i18n/locales/api-fr-FR.json +41 -12
- package/frontend-vue/package.json +1 -1
- package/frontend-vue/tests/defaultRoute.test.ts +94 -0
- package/frontend-vue/tests/format.test.ts +10 -1
- package/frontend-vue/tests/minuteHistogram.test.ts +51 -0
- package/frontend-vue/tests/registration.test.ts +6 -2
- package/frontend-vue/tests/requestDrawer.test.ts +13 -0
- package/frontend-vue/tests/routeExplorer.test.ts +35 -28
- package/package.json +4 -3
- package/skills/dms-api/SKILL.md +3 -1
- package/dist/pages/period.d.ts +0 -9
- package/dist/pages/period.js +0 -24
- package/dist/pages/period.js.map +0 -1
|
@@ -134,7 +134,7 @@ const origin = computed(() => {
|
|
|
134
134
|
const shortcutsOpen = ref(false)
|
|
135
135
|
|
|
136
136
|
// The table's search is the DMS table's own shortcut, set to "/" by the
|
|
137
|
-
// page (`searchShortcut`); J / K, Esc and L are the DMS
|
|
137
|
+
// page (`searchShortcut`); J / K, Esc and L are the DMS drawer's and
|
|
138
138
|
// live toggle's.
|
|
139
139
|
const SHORTCUTS = [
|
|
140
140
|
{ keys: ['/'], label: 'api.logs.shortcuts.search' },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
3
|
-
import { byteLength, formatMs } from '../../utils/format'
|
|
3
|
+
import { byteLength, formatMs, unbreakable } from '../../utils/format'
|
|
4
4
|
import { errorStatus } from '../../utils/http'
|
|
5
5
|
import {
|
|
6
6
|
durationScale,
|
|
@@ -22,16 +22,19 @@ import ApiKeyValues from '../internal/ApiKeyValues.vue'
|
|
|
22
22
|
import ApiStatusBadge from '../internal/ApiStatusBadge.vue'
|
|
23
23
|
import ApiTesterBadge from '../internal/ApiTesterBadge.vue'
|
|
24
24
|
|
|
25
|
-
// One captured request, in the DMS
|
|
26
|
-
// table's row opens (a `
|
|
27
|
-
// The DMS draws the
|
|
28
|
-
// ("POST /api/orders", its `rowTitle`),
|
|
29
|
-
// / next buttons, J / K and close, and the
|
|
30
|
-
// that names no stored request. Here, the top stays put: where the request
|
|
25
|
+
// One captured request, in the DMS drawer on the right, which a request
|
|
26
|
+
// table's row opens (a `drawer` row action, `src/pages/request-table.ts`).
|
|
27
|
+
// The DMS draws the drawer's header: the request's method and path
|
|
28
|
+
// ("POST /api/orders", its `rowTitle`), its position over the whole table
|
|
29
|
+
// ("3 of 26,120"), the previous / next buttons, J / K and close, and the
|
|
30
|
+
// not-found state of a `?record=` that names no stored request. Here, the top stays put: where the request
|
|
31
31
|
// went, how it ended, what to do with it. Below, the summary puts
|
|
32
32
|
// the error first, then what the request was and how long it took against
|
|
33
33
|
// the slow threshold; then what was sent and what came back. Every action
|
|
34
34
|
// leads somewhere: the tester, the route, the requests alike.
|
|
35
|
+
// The drawer's body scrolls and pads, as for every row drawer (dms#375):
|
|
36
|
+
// the top sticks under the drawer's header, both at its 16px inset with an
|
|
37
|
+
// inset divider, and the content lays out by the drawer's width.
|
|
35
38
|
|
|
36
39
|
interface RequestLog {
|
|
37
40
|
_id: string
|
|
@@ -192,6 +195,8 @@ const timing = computed(() =>
|
|
|
192
195
|
const ratio = computed(() =>
|
|
193
196
|
thresholdRatio(timing.value?.ratio ?? 0, locale.value),
|
|
194
197
|
)
|
|
198
|
+
/** A duration that never wraps between its number and its unit. */
|
|
199
|
+
const ms = (value: number) => unbreakable(formatMs(value, locale.value))
|
|
195
200
|
|
|
196
201
|
// --- the error, folded to six lines ---
|
|
197
202
|
const message = ref<HTMLElement | null>(null)
|
|
@@ -362,10 +367,10 @@ const dateFormat = useDateFormat()
|
|
|
362
367
|
</script>
|
|
363
368
|
|
|
364
369
|
<template>
|
|
365
|
-
<section class="
|
|
370
|
+
<section class="flex flex-col" :aria-busy="pending">
|
|
366
371
|
<header
|
|
367
372
|
v-if="log"
|
|
368
|
-
class="border-default bg-default sticky top-0 z-10 flex
|
|
373
|
+
class="border-default bg-default sticky top-0 z-10 flex flex-col gap-2.5 border-b"
|
|
369
374
|
>
|
|
370
375
|
<div class="flex min-w-0 items-center gap-1">
|
|
371
376
|
<bdi
|
|
@@ -384,7 +389,7 @@ const dateFormat = useDateFormat()
|
|
|
384
389
|
class="font-mono tabular-nums"
|
|
385
390
|
:class="timing.slow ? 'text-warning font-semibold' : 'text-muted'"
|
|
386
391
|
>
|
|
387
|
-
{{
|
|
392
|
+
{{ ms(log.responseTimeMs ?? 0) }}
|
|
388
393
|
</span>
|
|
389
394
|
<UTooltip v-else :text="t('api.request.not_measured_hint')">
|
|
390
395
|
<span class="text-dimmed font-mono" tabindex="0">
|
|
@@ -453,7 +458,7 @@ const dateFormat = useDateFormat()
|
|
|
453
458
|
/>
|
|
454
459
|
</header>
|
|
455
460
|
|
|
456
|
-
<div class="
|
|
461
|
+
<div :class="log ? 'pt-4' : ''">
|
|
457
462
|
<div v-if="pending" class="flex flex-col gap-3">
|
|
458
463
|
<USkeleton class="h-4 w-1/2" />
|
|
459
464
|
<USkeleton class="h-28 w-full" />
|
|
@@ -540,7 +545,7 @@ const dateFormat = useDateFormat()
|
|
|
540
545
|
<template v-if="timing">
|
|
541
546
|
<div class="flex flex-wrap items-baseline gap-x-2 gap-y-1">
|
|
542
547
|
<span class="text-highlighted font-mono text-xl font-semibold">
|
|
543
|
-
{{
|
|
548
|
+
{{ ms(log.responseTimeMs ?? 0) }}
|
|
544
549
|
</span>
|
|
545
550
|
<span
|
|
546
551
|
class="text-xs"
|
|
@@ -554,31 +559,15 @@ const dateFormat = useDateFormat()
|
|
|
554
559
|
: t('api.request.threshold_ratio', { ratio })
|
|
555
560
|
}}
|
|
556
561
|
</span>
|
|
557
|
-
<span
|
|
558
|
-
v-if="log.routeLatency"
|
|
559
|
-
class="text-dimmed font-mono text-xs tabular-nums"
|
|
560
|
-
>
|
|
561
|
-
{{
|
|
562
|
-
t(
|
|
563
|
-
'api.request.route_latency',
|
|
564
|
-
{
|
|
565
|
-
days: count(log.routeLatency.windowDays),
|
|
566
|
-
p50: formatMs(log.routeLatency.p50, locale),
|
|
567
|
-
p95: formatMs(log.routeLatency.p95, locale),
|
|
568
|
-
},
|
|
569
|
-
log.routeLatency.windowDays,
|
|
570
|
-
)
|
|
571
|
-
}}
|
|
572
|
-
</span>
|
|
573
562
|
</div>
|
|
574
563
|
<div
|
|
575
|
-
class="bg-elevated relative h-2 rounded-full"
|
|
564
|
+
class="bg-elevated relative my-1 h-2 rounded-full"
|
|
576
565
|
role="meter"
|
|
577
566
|
:aria-label="t('api.request.meter_label')"
|
|
578
567
|
aria-valuemin="0"
|
|
579
568
|
:aria-valuemax="Math.round(timing.max)"
|
|
580
569
|
:aria-valuenow="Math.round(log.responseTimeMs ?? 0)"
|
|
581
|
-
:aria-valuetext="
|
|
570
|
+
:aria-valuetext="ms(log.responseTimeMs ?? 0)"
|
|
582
571
|
>
|
|
583
572
|
<div
|
|
584
573
|
class="h-full rounded-full"
|
|
@@ -591,13 +580,30 @@ const dateFormat = useDateFormat()
|
|
|
591
580
|
aria-hidden="true"
|
|
592
581
|
/>
|
|
593
582
|
</div>
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
583
|
+
<!-- The threshold, then how the route does lately: each its own
|
|
584
|
+
line, at every width. -->
|
|
585
|
+
<div class="text-dimmed flex flex-col gap-1 text-xs">
|
|
586
|
+
<p>
|
|
587
|
+
{{
|
|
588
|
+
t('api.request.threshold', {
|
|
589
|
+
threshold: ms(log.slowThresholdMs),
|
|
590
|
+
})
|
|
591
|
+
}}
|
|
592
|
+
</p>
|
|
593
|
+
<p v-if="log.routeLatency" class="font-mono tabular-nums">
|
|
594
|
+
{{
|
|
595
|
+
t(
|
|
596
|
+
'api.request.route_latency',
|
|
597
|
+
{
|
|
598
|
+
days: count(log.routeLatency.windowDays),
|
|
599
|
+
p50: ms(log.routeLatency.p50),
|
|
600
|
+
p95: ms(log.routeLatency.p95),
|
|
601
|
+
},
|
|
602
|
+
log.routeLatency.windowDays,
|
|
603
|
+
)
|
|
604
|
+
}}
|
|
605
|
+
</p>
|
|
606
|
+
</div>
|
|
601
607
|
</template>
|
|
602
608
|
<p v-else class="text-dimmed text-sm">
|
|
603
609
|
{{ t('api.request.not_measured_hint') }}
|
|
@@ -190,10 +190,17 @@ async function copyCurl() {
|
|
|
190
190
|
/>
|
|
191
191
|
</DmsCard>
|
|
192
192
|
|
|
193
|
+
<!-- The lines of the header below, at their heights. -->
|
|
193
194
|
<DmsCard v-else-if="pending" :padded="false" class="px-5 py-4">
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
<div class="flex h-7 items-center">
|
|
196
|
+
<USkeleton class="h-3 w-40 max-w-full" />
|
|
197
|
+
</div>
|
|
198
|
+
<div class="mt-2 flex h-7 items-center">
|
|
199
|
+
<USkeleton class="h-7 w-72 max-w-full" />
|
|
200
|
+
</div>
|
|
201
|
+
<div class="mt-3 flex h-[1.5em] items-center text-[12.5px]">
|
|
202
|
+
<USkeleton class="h-3 w-96 max-w-full" />
|
|
203
|
+
</div>
|
|
197
204
|
</DmsCard>
|
|
198
205
|
|
|
199
206
|
<DmsCard v-else-if="!route" :padded="false" class="px-5 py-6">
|
|
@@ -226,19 +233,22 @@ async function copyCurl() {
|
|
|
226
233
|
/>
|
|
227
234
|
</DmsCard>
|
|
228
235
|
|
|
236
|
+
<!-- Each line keeps one height whatever its width and the font drawing
|
|
237
|
+
it: the actions sit on the folder's line, the path is cut rather
|
|
238
|
+
than wrapped (whole in its tooltip). -->
|
|
229
239
|
<DmsCard v-else :padded="false" class="px-5 py-4">
|
|
230
|
-
<
|
|
231
|
-
<
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
<div class="flex h-7 items-center gap-3">
|
|
241
|
+
<p
|
|
242
|
+
class="text-dimmed flex min-w-0 items-center gap-1.5 font-mono text-[11.5px]"
|
|
243
|
+
>
|
|
244
|
+
<UIcon name="i-ph-folder-simple" class="size-3.5 shrink-0" />
|
|
245
|
+
<span class="truncate">
|
|
246
|
+
{{ route.folder }}
|
|
247
|
+
<template v-if="route.controller">
|
|
248
|
+
· {{ route.controller }}
|
|
249
|
+
</template>
|
|
250
|
+
</span>
|
|
251
|
+
</p>
|
|
242
252
|
<span class="grow" />
|
|
243
253
|
<UButton
|
|
244
254
|
:to="requestsLink"
|
|
@@ -246,6 +256,7 @@ async function copyCurl() {
|
|
|
246
256
|
color="neutral"
|
|
247
257
|
variant="outline"
|
|
248
258
|
icon="i-ph-list-magnifying-glass"
|
|
259
|
+
class="shrink-0"
|
|
249
260
|
:label="t('api.routes.header.requests')"
|
|
250
261
|
/>
|
|
251
262
|
<UButton
|
|
@@ -254,10 +265,19 @@ async function copyCurl() {
|
|
|
254
265
|
color="neutral"
|
|
255
266
|
variant="outline"
|
|
256
267
|
icon="i-ph-terminal"
|
|
268
|
+
class="shrink-0"
|
|
257
269
|
:label="t('api.request.copy_curl')"
|
|
258
270
|
@click="copyCurl"
|
|
259
271
|
/>
|
|
260
272
|
</div>
|
|
273
|
+
<div class="mt-2 flex h-7 items-center gap-3">
|
|
274
|
+
<ApiMethodBadge :method="route.method" class="shrink-0" />
|
|
275
|
+
<ApiPath
|
|
276
|
+
:path="route.path"
|
|
277
|
+
class="text-highlighted text-xl font-semibold tracking-tight"
|
|
278
|
+
/>
|
|
279
|
+
<DmsCopyButton :value="route.path" />
|
|
280
|
+
</div>
|
|
261
281
|
<div
|
|
262
282
|
class="text-muted mt-3 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[12.5px]"
|
|
263
283
|
>
|
|
@@ -5,11 +5,9 @@ import {
|
|
|
5
5
|
bySeverity,
|
|
6
6
|
groupRoutes,
|
|
7
7
|
initialRoute,
|
|
8
|
-
lastRoute,
|
|
9
8
|
listedFolders,
|
|
10
9
|
needsAttention,
|
|
11
10
|
optionId,
|
|
12
|
-
rememberRoute,
|
|
13
11
|
type RouteState,
|
|
14
12
|
stepFrom,
|
|
15
13
|
windowParts,
|
|
@@ -81,6 +79,7 @@ const { formatLocale: locale, formatNumber } = useRegionalFormat({
|
|
|
81
79
|
locale: 'format',
|
|
82
80
|
})
|
|
83
81
|
const selection = useRouteSelection(props.queryKey)
|
|
82
|
+
const lastRoute = useLastRoute()
|
|
84
83
|
const { data, error, pending, refresh } = useApiData<{
|
|
85
84
|
routes: RouteRow[]
|
|
86
85
|
/** Minutes of traffic each state is judged on. */
|
|
@@ -332,14 +331,14 @@ function onSearchKey(event: KeyboardEvent) {
|
|
|
332
331
|
|
|
333
332
|
onBeforeUnmount(stopSettling)
|
|
334
333
|
|
|
335
|
-
// A page opened without a route
|
|
336
|
-
//
|
|
337
|
-
//
|
|
334
|
+
// A page opened without a route lands on one before it renders
|
|
335
|
+
// (`middleware/defaultRoute.ts`). Should the list come in only now, the
|
|
336
|
+
// route it opens on is picked here, without a history entry of its own.
|
|
338
337
|
watch(
|
|
339
338
|
routes,
|
|
340
339
|
(all) => {
|
|
341
340
|
if (selection.ref.value || all.length === 0) return
|
|
342
|
-
const first = initialRoute(all, lastRoute
|
|
341
|
+
const first = initialRoute(all, lastRoute.value)
|
|
343
342
|
if (first) void selection.select(first.ref, { replace: true })
|
|
344
343
|
},
|
|
345
344
|
{ immediate: true },
|
|
@@ -347,7 +346,7 @@ watch(
|
|
|
347
346
|
|
|
348
347
|
watch(selection.ref, (current) => {
|
|
349
348
|
if (!settle) cursor.value = null
|
|
350
|
-
if (current)
|
|
349
|
+
if (current) lastRoute.value = current
|
|
351
350
|
})
|
|
352
351
|
|
|
353
352
|
// The selected route is never hidden: its folder opens and the list
|
|
@@ -365,7 +364,7 @@ watch(
|
|
|
365
364
|
{ flush: 'post' },
|
|
366
365
|
)
|
|
367
366
|
onMounted(() => {
|
|
368
|
-
if (selection.ref.value)
|
|
367
|
+
if (selection.ref.value) lastRoute.value = selection.ref.value
|
|
369
368
|
// Once the list is laid out.
|
|
370
369
|
void nextTick(() => revealActive(true))
|
|
371
370
|
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** Cookie of the route last opened, for the browser session. */
|
|
4
|
+
const LAST_ROUTE_COOKIE = 'dms-api-last-route'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The route last opened on the Routes page in this browser session. A
|
|
8
|
+
* cookie, so the server reads it too: a visit naming no route lands on it
|
|
9
|
+
* before the page renders (`middleware/defaultRoute.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export function useLastRoute(): Ref<string | null> {
|
|
12
|
+
return useDmsCookie<string | null>(LAST_ROUTE_COOKIE, {
|
|
13
|
+
default: () => null,
|
|
14
|
+
sameSite: 'lax',
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useLastRoute } from '../composables/useLastRoute'
|
|
2
|
+
import {
|
|
3
|
+
defaultRouteLocation,
|
|
4
|
+
type ExplorerRoute,
|
|
5
|
+
ROUTE_QUERY_KEY,
|
|
6
|
+
ROUTES_PAGE_PATH,
|
|
7
|
+
} from '../utils/routeExplorer'
|
|
8
|
+
|
|
9
|
+
/** The list the Routes page's `RouteTree` reads (`src/pages/routes.ts`). */
|
|
10
|
+
const LIST_URL = '/api/monitoring/routes/list'
|
|
11
|
+
|
|
12
|
+
// A visit of the Routes page naming no route lands on one before the page
|
|
13
|
+
// renders: the last one opened in this browser session, else the one needing
|
|
14
|
+
// a look first. The server answers a reload with the address that names it,
|
|
15
|
+
// and a link followed in the browser goes straight there, so the header and
|
|
16
|
+
// the tabs render with the page rather than once the list has loaded.
|
|
17
|
+
// Without the list (signed out, a failed read), the page opens as it is.
|
|
18
|
+
export default defineDmsMiddleware(async (to) => {
|
|
19
|
+
if (to.path !== ROUTES_PAGE_PATH || to.query[ROUTE_QUERY_KEY]) return
|
|
20
|
+
if (!useDmsUserSession().loggedIn.value) return
|
|
21
|
+
// Read before the request: the render's context is gone after an await.
|
|
22
|
+
const last = useLastRoute().value
|
|
23
|
+
const { $authFetch } = useAuthFetch()
|
|
24
|
+
let routes: ExplorerRoute[]
|
|
25
|
+
try {
|
|
26
|
+
;({ routes } = await $authFetch<{ routes: ExplorerRoute[] }>(LIST_URL))
|
|
27
|
+
} catch {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
return defaultRouteLocation(to, routes, last)
|
|
31
|
+
})
|
|
@@ -136,6 +136,15 @@ export function formatMs(value: number, locale?: string): string {
|
|
|
136
136
|
return `${formatCount(value, locale)} ms`
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* A value written with its unit ("68 ms", "< 1 ms") that never wraps
|
|
141
|
+
* between the two: its spaces become no-break spaces. A narrow drawer
|
|
142
|
+
* breaks a line of figures between them, never inside one.
|
|
143
|
+
*/
|
|
144
|
+
export function unbreakable(text: string): string {
|
|
145
|
+
return text.replace(/ /g, '\u00A0')
|
|
146
|
+
}
|
|
147
|
+
|
|
139
148
|
/**
|
|
140
149
|
* A duration threshold (the slow threshold of the settings), the one way
|
|
141
150
|
* every page writes it: "800 ms" under a second, "1 s", "1.5 s" from one.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
// The live histogram above the request logs: one bar per
|
|
2
|
-
//
|
|
1
|
+
// The live histogram above the request logs: one bar per stretch of the
|
|
2
|
+
// page's period (a minute over the last hour, 15 minutes over 24 hours, up
|
|
3
|
+
// to 6 hours over 30 days: the server picks it), stacked by status class, on
|
|
4
|
+
// a scale a single spike cannot flatten.
|
|
3
5
|
|
|
4
6
|
const MS_PER_MINUTE = 60_000
|
|
7
|
+
const MS_PER_HOUR = 60 * MS_PER_MINUTE
|
|
8
|
+
const MS_PER_DAY = 24 * MS_PER_HOUR
|
|
5
9
|
|
|
6
|
-
/** One
|
|
10
|
+
/** One bar of the histogram, as `/api/monitoring/logs/live` sends it. */
|
|
7
11
|
export interface MinuteBucket {
|
|
8
12
|
start: number
|
|
9
13
|
/** Every answer below 400: 2xx and 3xx. */
|
|
@@ -47,25 +51,21 @@ export function scaleCeiling(totals: number[]): number {
|
|
|
47
51
|
: peak
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
/** The minute `at` falls in, as the start of its bucket. */
|
|
51
|
-
export function minuteOf(at: number): number {
|
|
52
|
-
return Math.floor(at / MS_PER_MINUTE) * MS_PER_MINUTE
|
|
53
|
-
}
|
|
54
|
-
|
|
55
54
|
/**
|
|
56
|
-
* The bars of `buckets` on their scale. The
|
|
57
|
-
* the one still running
|
|
55
|
+
* The bars of `buckets`, each `bucketMs` long, on their scale. The bar
|
|
56
|
+
* holding `refreshedAt` is the one still running (none over a past range:
|
|
57
|
+
* leave `refreshedAt` out). An empty bar has no segment: nothing is drawn.
|
|
58
58
|
*/
|
|
59
59
|
export function minuteBars(
|
|
60
60
|
buckets: MinuteBucket[],
|
|
61
61
|
refreshedAt?: string | number,
|
|
62
|
+
bucketMs: number = MS_PER_MINUTE,
|
|
62
63
|
): { bars: MinuteBar[]; ceiling: number; clipped: boolean } {
|
|
63
64
|
const totals = buckets.map(
|
|
64
65
|
(bucket) => bucket.success + bucket.clientErrors + bucket.serverErrors,
|
|
65
66
|
)
|
|
66
67
|
const ceiling = scaleCeiling(totals)
|
|
67
68
|
const at = refreshedAt === undefined ? NaN : new Date(refreshedAt).getTime()
|
|
68
|
-
const currentMinute = Number.isNaN(at) ? undefined : minuteOf(at)
|
|
69
69
|
const bars = buckets.map((bucket, index) => {
|
|
70
70
|
const total = totals[index]
|
|
71
71
|
const shown = Math.min(total, ceiling)
|
|
@@ -75,7 +75,7 @@ export function minuteBars(
|
|
|
75
75
|
return {
|
|
76
76
|
...bucket,
|
|
77
77
|
total,
|
|
78
|
-
current: bucket.start
|
|
78
|
+
current: bucket.start <= at && at < bucket.start + bucketMs,
|
|
79
79
|
clipped: total > ceiling,
|
|
80
80
|
heights: {
|
|
81
81
|
success: percent(bucket.success),
|
|
@@ -103,14 +103,49 @@ export function axisTicks(bars: MinuteBar[]): number[] {
|
|
|
103
103
|
return [...new Set([0, Math.floor(last / 2), last])]
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The length of a bar, as its title names it: "minute", "15 min", "6 h",
|
|
108
|
+
* "day".
|
|
109
|
+
*/
|
|
110
|
+
export type BucketLabel =
|
|
111
|
+
| { unit: 'minute' }
|
|
112
|
+
| { unit: 'minutes' | 'hours'; amount: number }
|
|
113
|
+
| { unit: 'day' }
|
|
114
|
+
|
|
115
|
+
export function bucketLabel(bucketMs: number): BucketLabel {
|
|
116
|
+
if (bucketMs <= MS_PER_MINUTE) return { unit: 'minute' }
|
|
117
|
+
if (bucketMs < MS_PER_HOUR)
|
|
118
|
+
return { unit: 'minutes', amount: Math.round(bucketMs / MS_PER_MINUTE) }
|
|
119
|
+
if (bucketMs < MS_PER_DAY)
|
|
120
|
+
return { unit: 'hours', amount: Math.round(bucketMs / MS_PER_HOUR) }
|
|
121
|
+
return { unit: 'day' }
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* How the axis, the tooltip and the summary write a bar's time: the time
|
|
126
|
+
* alone over a day at most, the date and time over longer periods, the date
|
|
127
|
+
* alone for bars of a day.
|
|
128
|
+
*/
|
|
129
|
+
export type BarTimeFormat = 'time' | 'dateTime' | 'date'
|
|
130
|
+
|
|
131
|
+
export function barTimeFormat(bucketMs: number, spanMs: number): BarTimeFormat {
|
|
132
|
+
if (bucketMs >= MS_PER_DAY) return 'date'
|
|
133
|
+
return spanMs > MS_PER_DAY ? 'dateTime' : 'time'
|
|
134
|
+
}
|
|
135
|
+
|
|
106
136
|
/**
|
|
107
137
|
* What the histogram's live indicator says: following the page's live mode,
|
|
108
|
-
* paused with it,
|
|
109
|
-
* failure).
|
|
138
|
+
* paused with it, reconnecting since the last read failed (from the first
|
|
139
|
+
* failure), or a past range, which nothing updates.
|
|
110
140
|
*/
|
|
111
|
-
export type LiveStatus = 'live' | 'paused' | 'reconnecting'
|
|
141
|
+
export type LiveStatus = 'live' | 'paused' | 'reconnecting' | 'past'
|
|
112
142
|
|
|
113
|
-
export function liveStatus(
|
|
143
|
+
export function liveStatus(
|
|
144
|
+
live: boolean,
|
|
145
|
+
failures: number,
|
|
146
|
+
followsNow = true,
|
|
147
|
+
): LiveStatus {
|
|
148
|
+
if (!followsNow) return failures > 0 ? 'reconnecting' : 'past'
|
|
114
149
|
if (!live) return 'paused'
|
|
115
150
|
return failures > 0 ? 'reconnecting' : 'live'
|
|
116
151
|
}
|
|
@@ -186,21 +186,29 @@ export function windowParts(minutes: number): {
|
|
|
186
186
|
return { unit: 'min', amount: minutes }
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/** The route last opened in this tab, if the browser lets us keep it. */
|
|
192
|
-
export function lastRoute(): string | null {
|
|
193
|
-
try {
|
|
194
|
-
return window.sessionStorage.getItem(LAST_ROUTE_KEY)
|
|
195
|
-
} catch {
|
|
196
|
-
return null
|
|
197
|
-
}
|
|
198
|
-
}
|
|
189
|
+
/** The Routes page, which a visit naming no route lands on with one. */
|
|
190
|
+
export const ROUTES_PAGE_PATH = '/modules/api/routes'
|
|
199
191
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
/** Query parameter holding the selected route, as `METHOD /path`. */
|
|
193
|
+
export const ROUTE_QUERY_KEY = 'route'
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The address a visit of the Routes page naming no route is sent to: the
|
|
197
|
+
* same page with `?route=` the route `initialRoute` picks, the rest of its
|
|
198
|
+
* query kept. Undefined when the visit names one already, or when there is
|
|
199
|
+
* no route to pick.
|
|
200
|
+
*/
|
|
201
|
+
export function defaultRouteLocation(
|
|
202
|
+
to: { path: string; query: Record<string, unknown> },
|
|
203
|
+
routes: ExplorerRoute[],
|
|
204
|
+
last: string | null,
|
|
205
|
+
): { path: string; query: Record<string, unknown> } | undefined {
|
|
206
|
+
const named = to.query[ROUTE_QUERY_KEY]
|
|
207
|
+
if (typeof named === 'string' && named) return undefined
|
|
208
|
+
const first = initialRoute(routes, last)
|
|
209
|
+
if (!first) return undefined
|
|
210
|
+
return {
|
|
211
|
+
path: to.path,
|
|
212
|
+
query: { ...to.query, [ROUTE_QUERY_KEY]: first.ref },
|
|
205
213
|
}
|
|
206
214
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineAsyncComponent, type Component } from 'vue'
|
|
2
2
|
import type { DmsFrontendModule } from '#dms/frontend-module'
|
|
3
|
+
import defaultRoute from './app/middleware/defaultRoute'
|
|
3
4
|
import displays from './app/plugins/displays'
|
|
4
5
|
|
|
5
6
|
interface VueModule {
|
|
@@ -26,6 +27,10 @@ const frontendModule: DmsFrontendModule = {
|
|
|
26
27
|
}
|
|
27
28
|
// Universal: the request tables draw their cells in the server render too.
|
|
28
29
|
sdk.registerPlugin(displays, { clientOnly: false })
|
|
30
|
+
// The Routes page opened without a route lands on one, on the server too.
|
|
31
|
+
sdk.registerMiddleware('dms-api-default-route', defaultRoute, {
|
|
32
|
+
global: true,
|
|
33
|
+
})
|
|
29
34
|
},
|
|
30
35
|
}
|
|
31
36
|
|
|
@@ -150,7 +150,6 @@
|
|
|
150
150
|
"title": "Beta",
|
|
151
151
|
"description": "The API console is read-only for now: inspect, monitor and test routes."
|
|
152
152
|
},
|
|
153
|
-
"no_previous": "No previous period to compare with",
|
|
154
153
|
"traffic": {
|
|
155
154
|
"title": "Traffic & errors",
|
|
156
155
|
"2xx": "2xx success",
|
|
@@ -221,7 +220,19 @@
|
|
|
221
220
|
}
|
|
222
221
|
},
|
|
223
222
|
"live": {
|
|
224
|
-
"title": "Requests per
|
|
223
|
+
"title": "Requests per {bucket} · {period} · all traffic",
|
|
224
|
+
"title_pending": "Requests · all traffic",
|
|
225
|
+
"bucket_minute": "minute",
|
|
226
|
+
"bucket_minutes": "{amount} min",
|
|
227
|
+
"bucket_hours": "{amount} h",
|
|
228
|
+
"bucket_day": "day",
|
|
229
|
+
"period_last-hour": "last hour",
|
|
230
|
+
"period_last-24h": "last 24 h",
|
|
231
|
+
"period_last-7-days": "last 7 days",
|
|
232
|
+
"period_last-30-days": "last 30 days",
|
|
233
|
+
"period_all": "all kept logs",
|
|
234
|
+
"period_custom": "{from} – {to}",
|
|
235
|
+
"past": "Past range · not live",
|
|
225
236
|
"kept": "Kept {days} days · bodies up to {size}",
|
|
226
237
|
"kept_days": "Kept {days} days",
|
|
227
238
|
"kept_no_bodies": "Kept {days} days · bodies not captured",
|
|
@@ -234,14 +245,14 @@
|
|
|
234
245
|
"paused": "Paused",
|
|
235
246
|
"last_data": "data from {time}",
|
|
236
247
|
"no_data_yet": "no data yet",
|
|
237
|
-
"error": "Could not load the
|
|
248
|
+
"error": "Could not load the request histogram",
|
|
238
249
|
"error_description": "The graph tries again at the next refresh.",
|
|
239
|
-
"scale": "Scale up to {count} per
|
|
240
|
-
"scale_cut": "
|
|
250
|
+
"scale": "Scale up to {count} per {bucket}",
|
|
251
|
+
"scale_cut": "taller bars are cut",
|
|
241
252
|
"tooltip_none": "no request",
|
|
242
|
-
"tooltip_current": "
|
|
243
|
-
"summary": "Requests per
|
|
244
|
-
"summary_empty": "No request
|
|
253
|
+
"tooltip_current": "in progress",
|
|
254
|
+
"summary": "Requests per {bucket}, {period}: {total} requests, {client} 4xx, {server} 5xx. Busiest: {peak} at {time}.",
|
|
255
|
+
"summary_empty": "No request in this period."
|
|
245
256
|
},
|
|
246
257
|
"live_mode": {
|
|
247
258
|
"verdict": {
|
|
@@ -376,7 +387,7 @@
|
|
|
376
387
|
"slow_ratio": "Slow · {ratio}× the threshold",
|
|
377
388
|
"threshold_ratio": "{ratio}× the slow threshold",
|
|
378
389
|
"threshold": "Slow threshold {threshold}, as set now.",
|
|
379
|
-
"route_latency": "This route, last day: p50
|
|
390
|
+
"route_latency": "This route, last day: p50\u00a0{p50} · p95\u00a0{p95} | This route, last {days} days: p50\u00a0{p50} · p95\u00a0{p95}",
|
|
380
391
|
"meter_label": "Duration against the slow threshold",
|
|
381
392
|
"not_measured": "not measured",
|
|
382
393
|
"not_measured_hint": "Not measured: the request was turned away before reaching a handler.",
|
|
@@ -418,7 +429,6 @@
|
|
|
418
429
|
"forbidden_description": "Your role shows this list but not the detail of its requests. Ask an administrator for access to Request logs.",
|
|
419
430
|
"error_title": "Could not open this request",
|
|
420
431
|
"error_description": "The console did not answer. Try again.",
|
|
421
|
-
"position": "Request {index} of {total} shown",
|
|
422
432
|
"heading": "{method} {path}"
|
|
423
433
|
},
|
|
424
434
|
"routes": {
|
|
@@ -516,8 +526,6 @@
|
|
|
516
526
|
"rate": "{rate}",
|
|
517
527
|
"error_split": "{client} × 4xx · {server} × 5xx",
|
|
518
528
|
"slow_line": "slow above {threshold}",
|
|
519
|
-
"no_baseline": "No previous period",
|
|
520
|
-
"vs_previous": "{delta} vs. previous period",
|
|
521
529
|
"summary": "Route figures",
|
|
522
530
|
"p95_detail": "p95 {p95}",
|
|
523
531
|
"p95_none": "No p95 kept over the period",
|
|
@@ -861,6 +869,27 @@
|
|
|
861
869
|
"adjusted_min": "{typed} is below the minimum: set to {value}.",
|
|
862
870
|
"adjusted_step": "{typed} is not a step of {step}: rounded to {value}."
|
|
863
871
|
}
|
|
872
|
+
},
|
|
873
|
+
"compare": {
|
|
874
|
+
"series": {
|
|
875
|
+
"previous_period": "Previous period",
|
|
876
|
+
"custom": "Compared period"
|
|
877
|
+
},
|
|
878
|
+
"versus": {
|
|
879
|
+
"previous_period": "{delta} vs. {previous} previous period",
|
|
880
|
+
"custom": "{delta} vs. {previous} compared period"
|
|
881
|
+
},
|
|
882
|
+
"from_zero": {
|
|
883
|
+
"previous_period": "none over the previous period",
|
|
884
|
+
"custom": "none over the compared period"
|
|
885
|
+
},
|
|
886
|
+
"no_baseline": {
|
|
887
|
+
"previous_period": "No previous period",
|
|
888
|
+
"custom": "No data over the compared period"
|
|
889
|
+
},
|
|
890
|
+
"change_percent": "{sign}{value}",
|
|
891
|
+
"change_points": "{sign}{value} pt",
|
|
892
|
+
"with": "{detail} · {versus}"
|
|
864
893
|
}
|
|
865
894
|
}
|
|
866
895
|
}
|