Skip to content

Commit 6017944

Browse files
committed
fix(webapp): guard workload auth gate metric against dev HMR re-registration
1 parent 14fa906 commit 6017944

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

apps/webapp/app/v3/services/worker/workerGroupTokenService.server.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ if (workloadCreatedAtGateEnabled && !workloadTokenCutoff) {
6262

6363
type WorkloadGateAction = "start" | "complete" | "continue" | "snapshots_since";
6464

65-
const workloadAuthGateCounter = new Counter({
66-
name: "workload_auth_gate_total",
67-
help: "Deployment token authorization outcomes on worker actions",
68-
labelNames: ["outcome", "action"] as const,
69-
registers: [metricsRegister],
70-
});
65+
// singleton: module-scope registration double-registers under dev HMR
66+
const workloadAuthGateCounter = singleton(
67+
"workloadAuthGateCounter",
68+
() =>
69+
new Counter({
70+
name: "workload_auth_gate_total",
71+
help: "Deployment token authorization outcomes on worker actions",
72+
labelNames: ["outcome", "action"] as const,
73+
registers: [metricsRegister],
74+
})
75+
);
7176

7277
function createAuthenticatedWorkerInstanceCache() {
7378
return createCache({

0 commit comments

Comments
 (0)