Guard collectDefaultMetrics against duplicate registration
Importing metrics.server.ts from yjs-server.ts caused collectDefaultMetrics() to re-register during HMR, crashing the planner dev server. Check if metrics already exist first. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e083ee134d
commit
a3ad073d96
1 changed files with 4 additions and 1 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import client from "prom-client";
|
||||
|
||||
// Collect default Node.js metrics (event loop, heap, GC)
|
||||
client.collectDefaultMetrics();
|
||||
// Guard against duplicate registration during HMR
|
||||
if (!client.register.getSingleMetric("process_cpu_user_seconds_total")) {
|
||||
client.collectDefaultMetrics();
|
||||
}
|
||||
|
||||
export const httpRequestDuration = new client.Histogram({
|
||||
name: "http_request_duration_seconds",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue