fix(metrics): don't assign a timestamp to Prometheus metrics, let the scraper assign the timestamp to the time series

This commit is contained in:
perf3ct 2025-07-15 20:39:36 +00:00
parent fc98240614
commit c0dfee8439
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232

View File

@ -43,7 +43,6 @@ interface MetricsData {
*/
function formatPrometheusMetrics(data: MetricsData): string {
const lines: string[] = [];
const timestamp = Math.floor(new Date(data.timestamp).getTime() / 1000);
// Helper function to add a metric
const addMetric = (name: string, value: number | null, help: string, type: string = 'gauge', labels: Record<string, string> = {}) => {
@ -56,7 +55,7 @@ function formatPrometheusMetrics(data: MetricsData): string {
? `{${Object.entries(labels).map(([k, v]) => `${k}="${v}"`).join(',')}}`
: '';
lines.push(`${name}${labelStr} ${value} ${timestamp}`);
lines.push(`${name}${labelStr} ${value}`);
lines.push('');
};