Skip to content

Commit 84add4a

Browse files
authored
feat(supervisor): export workload_token_enforcement_mode gauge (#4335)
Add a Prometheus gauge `workload_token_enforcement_mode` set to 1 for the active `WORKLOAD_TOKEN_ENFORCEMENT` value (`disabled`/`log`/`enforce`), emitted at startup on the shared registry. The existing mint/verify counters don't distinguish `log` from `enforce` (the verify outcome is recorded before the reject decision), so dashboards can't tell which mode a cluster is running. This gauge makes the active mode queryable at a glance. Supervisor typecheck passes.
1 parent 509a459 commit 84add4a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

apps/supervisor/src/workloadToken.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
type WorkloadDeploymentTokenClaims,
55
type WorkloadDeploymentTokenInput,
66
} from "@trigger.dev/core/v3";
7-
import { Counter } from "prom-client";
7+
import { Counter, Gauge } from "prom-client";
88
import { env } from "./env.js";
99
import { register } from "./metrics.js";
1010

@@ -37,6 +37,16 @@ const verifyCounter = new Counter({
3737
registers: [register],
3838
});
3939

40+
// Exports the active mode (value 1 for the current WORKLOAD_TOKEN_ENFORCEMENT) so dashboards can show
41+
// disabled/log/enforce at a glance — the counters alone don't distinguish log from enforce.
42+
const enforcementModeGauge = new Gauge({
43+
name: "workload_token_enforcement_mode",
44+
help: "Active runner-boundary auth mode: value 1 for the label matching WORKLOAD_TOKEN_ENFORCEMENT",
45+
labelNames: ["mode"] as const,
46+
registers: [register],
47+
});
48+
enforcementModeGauge.set({ mode: env.WORKLOAD_TOKEN_ENFORCEMENT }, 1);
49+
4050
export async function mintDeploymentToken(
4151
claims: WorkloadDeploymentTokenInput
4252
): Promise<string | undefined> {

0 commit comments

Comments
 (0)