feat(observability): delivery metrics, admin metrics/delivery endpoints, admin API route wiring

This commit is contained in:
RhenCloud 2026-08-15 17:03:02 +08:00
parent 2470bd786d
commit 1e9ba3c5dd
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
17 changed files with 682 additions and 7 deletions

View file

@ -0,0 +1,24 @@
import type { DeliveryMetrics } from "~/types";
export function useMetrics() {
const { needLogin } = useAuthState();
const metrics = ref<DeliveryMetrics | null>(null);
const loading = ref(false);
const error = ref("");
async function load(): Promise<void> {
loading.value = true;
error.value = "";
needLogin.value = false;
try {
const data = await apiFetch<{ metrics?: DeliveryMetrics }>("/admin/api/metrics");
metrics.value = data.metrics ?? null;
} catch (err) {
if (!needLogin.value) error.value = err instanceof Error ? err.message : String(err);
} finally {
loading.value = false;
}
}
return { metrics, loading, error, load };
}