Show configured metrics retention (Refs #141)
This commit is contained in:
@@ -145,6 +145,8 @@ export interface AutoscalingMetrics {
|
||||
|
||||
export interface MetricsData {
|
||||
days: MetricsDays;
|
||||
/** Configured occupancy history retention; zero keeps samples indefinitely. */
|
||||
metricsKeepDays: number;
|
||||
since: number;
|
||||
now: number;
|
||||
/** Retained sample timestamps describe collection, not gameplay freshness. */
|
||||
|
||||
@@ -507,6 +507,7 @@ export function readMetrics(input: MetricsDays | MetricsQuery, now = Date.now())
|
||||
};
|
||||
return {
|
||||
days,
|
||||
metricsKeepDays: fleetSettings().metricsKeepDays,
|
||||
since,
|
||||
now,
|
||||
...metadata,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { parentPort } from 'node:worker_threads';
|
||||
import { db } from '../db/index.js';
|
||||
import { fleetSettings } from '../settings.js';
|
||||
import { readMetrics } from '../fleet/metrics.js';
|
||||
import { getLeaderboard, getPlayerLeaderboardEntry } from '../fleet/leaderboard.js';
|
||||
import { getPlayerProfile } from '../fleet/player-profile.js';
|
||||
@@ -28,6 +29,8 @@ parentPort!.on('message', ({ id, kind, input }) => {
|
||||
const key = JSON.stringify([
|
||||
kind,
|
||||
revision,
|
||||
// Retention edits must be visible even without new occupancy samples.
|
||||
kind === 'metrics' ? fleetSettings().metricsKeepDays : null,
|
||||
timed ? Math.floor(now / 30_000) : 0,
|
||||
timed ? input.query : input
|
||||
]);
|
||||
|
||||
@@ -44,6 +44,8 @@ function validReport(value: unknown): value is MetricsData {
|
||||
if (
|
||||
!record(value) ||
|
||||
![1, 7, 30].includes(value.days as number) ||
|
||||
!nonnegative(value.metricsKeepDays) ||
|
||||
!Number.isInteger(value.metricsKeepDays) ||
|
||||
!numeric(value.now) ||
|
||||
!numeric(value.since) ||
|
||||
!totals(value.summary) ||
|
||||
|
||||
Reference in New Issue
Block a user