[grade=pending] QA sprint: commit 103 at-risk files from multi-agent sprint work
Committed by Hermes autonomous QA sprint 2026-08-13. These files were modified during the Aug 12 sprint but never committed.
This commit is contained in:
@@ -110,6 +110,56 @@ class Metrics {
|
||||
this.requests = { total: 0, byStatus: {}, byMethod: {}, byPath: {} };
|
||||
this.errors = { total: 0, byType: {} };
|
||||
}
|
||||
|
||||
/**
|
||||
* DC-097: Prometheus text-format export for /metrics/prometheus
|
||||
* Returns standard Prometheus exposition format text.
|
||||
*/
|
||||
toPrometheus() {
|
||||
const uptimeSec = Math.floor((Date.now() - this.startTime) / 1000);
|
||||
const mem = process.memoryUsage();
|
||||
const lines = [];
|
||||
|
||||
lines.push('# HELP dashcaddy_uptime_seconds Server uptime in seconds');
|
||||
lines.push('# TYPE dashcaddy_uptime_seconds counter');
|
||||
lines.push(`dashcaddy_uptime_seconds ${uptimeSec}`);
|
||||
|
||||
lines.push('# HELP dashcaddy_requests_total Total HTTP requests');
|
||||
lines.push('# TYPE dashcaddy_requests_total counter');
|
||||
lines.push(`dashcaddy_requests_total ${this.requests.total}`);
|
||||
|
||||
for (const [status, count] of Object.entries(this.requests.byStatus || {})) {
|
||||
lines.push(`dashcaddy_requests_by_status{status="${status}"} ${count}`);
|
||||
}
|
||||
|
||||
for (const [method, count] of Object.entries(this.requests.byMethod || {})) {
|
||||
lines.push(`dashcaddy_requests_by_method{method="${method}"} ${count}`);
|
||||
}
|
||||
|
||||
lines.push('# HELP dashcaddy_errors_total Total errors');
|
||||
lines.push('# TYPE dashcaddy_errors_total counter');
|
||||
lines.push(`dashcaddy_errors_total ${this.errors.total}`);
|
||||
|
||||
lines.push('# HELP dashcaddy_containers_deployed Total containers deployed');
|
||||
lines.push('# TYPE dashcaddy_containers_deployed counter');
|
||||
lines.push(`dashcaddy_containers_deployed ${this.business.containersDeployed}`);
|
||||
|
||||
lines.push('# HELP dashcaddy_process_memory_heap_used_bytes Heap memory used');
|
||||
lines.push('# TYPE dashcaddy_process_memory_heap_used_bytes gauge');
|
||||
lines.push(`dashcaddy_process_memory_heap_used_bytes ${mem.heapUsed}`);
|
||||
|
||||
lines.push('# HELP dashcaddy_process_memory_heap_total_bytes Heap memory allocated');
|
||||
lines.push('# TYPE dashcaddy_process_memory_heap_total_bytes gauge');
|
||||
lines.push(`dashcaddy_process_memory_heap_total_bytes ${mem.heapTotal}`);
|
||||
|
||||
lines.push('# HELP dashcaddy_business_metric Business metrics');
|
||||
lines.push('# TYPE dashcaddy_business_metric counter');
|
||||
for (const [key, val] of Object.entries(this.business)) {
|
||||
lines.push(`dashcaddy_business_metric{metric="${key}"} ${val}`);
|
||||
}
|
||||
|
||||
return lines.join('\n') + '\n';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Metrics();
|
||||
|
||||
Reference in New Issue
Block a user