Skip to content

Commit f446dfa

Browse files
authored
feat: disable runner debug logs by default (#3992)
Runners were POSTing a debug log to the supervisor for every log line - one request per line, unbatched and unconditional. The supervisor already has a `SEND_RUN_DEBUG_LOGS` toggle (off by default) that discards them on receipt, but the runner fired the request regardless, so the traffic hit the supervisor either way. This gates the send at the source. The runner now reads `TRIGGER_SEND_RUN_DEBUG_LOGS` (off by default, injected by the supervisor from its existing `SEND_RUN_DEBUG_LOGS` setting) and skips the POST entirely when disabled. Local log output is unchanged. Dev runs use a separate path and are unaffected.
1 parent 56e301e commit f446dfa

7 files changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Runner debug logs are now disabled by default. Set `SEND_RUN_DEBUG_LOGS=true` on the supervisor to re-enable them.

apps/supervisor/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class ManagedSupervisor {
157157
instanceName: env.TRIGGER_WORKER_INSTANCE_NAME,
158158
otelEndpoint: env.OTEL_EXPORTER_OTLP_ENDPOINT,
159159
prettyLogs: env.RUNNER_PRETTY_LOGS,
160+
sendRunDebugLogs: env.SEND_RUN_DEBUG_LOGS,
160161
},
161162
createRetry: {
162163
maxAttempts: env.COMPUTE_INSTANCE_CREATE_MAX_ATTEMPTS,

apps/supervisor/src/workloadManager/compute.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type ComputeWorkloadManagerOptions = WorkloadManagerOptions & {
7575
instanceName: string;
7676
otelEndpoint: string;
7777
prettyLogs: boolean;
78+
sendRunDebugLogs: boolean;
7879
};
7980
createRetry?: {
8081
maxAttempts: number;
@@ -162,6 +163,7 @@ export class ComputeWorkloadManager implements WorkloadManager {
162163
TRIGGER_MACHINE_CPU: String(opts.machine.cpu),
163164
TRIGGER_MACHINE_MEMORY: String(opts.machine.memory),
164165
PRETTY_LOGS: String(this.opts.runner.prettyLogs),
166+
TRIGGER_SEND_RUN_DEBUG_LOGS: String(this.opts.runner.sendRunDebugLogs),
165167
};
166168

167169
if (this.opts.warmStartUrl) {

apps/supervisor/src/workloadManager/docker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export class DockerWorkloadManager implements WorkloadManager {
8484
`TRIGGER_MACHINE_CPU=${opts.machine.cpu}`,
8585
`TRIGGER_MACHINE_MEMORY=${opts.machine.memory}`,
8686
`PRETTY_LOGS=${env.RUNNER_PRETTY_LOGS}`,
87+
`TRIGGER_SEND_RUN_DEBUG_LOGS=${env.SEND_RUN_DEBUG_LOGS}`,
8788
];
8889

8990
if (this.opts.warmStartUrl) {

apps/supervisor/src/workloadManager/kubernetes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ export class KubernetesWorkloadManager implements WorkloadManager {
208208
name: "TRIGGER_MACHINE_MEMORY",
209209
value: `${opts.machine.memory}`,
210210
},
211+
{
212+
name: "TRIGGER_SEND_RUN_DEBUG_LOGS",
213+
value: `${env.SEND_RUN_DEBUG_LOGS}`,
214+
},
211215
{
212216
name: "LIMITS_CPU",
213217
valueFrom: {

packages/cli-v3/src/entryPoints/managed/env.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ const DateEnv = z
88
.transform((val) => new Date(parseInt(val, 10)))
99
.pipe(z.date());
1010

11+
const BoolEnv = z.preprocess((val) => {
12+
if (typeof val !== "string") {
13+
return val;
14+
}
15+
return ["true", "1"].includes(val.toLowerCase().trim());
16+
}, z.boolean());
17+
1118
// All IDs are friendly IDs
1219
const Env = z.object({
1320
// Set at build time
@@ -47,6 +54,9 @@ const Env = z.object({
4754
TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS: z.coerce.number().default(5),
4855
TRIGGER_SUCCESS_EXIT_CODE: z.coerce.number().default(0),
4956
TRIGGER_FAILURE_EXIT_CODE: z.coerce.number().default(1),
57+
58+
// Gates the per-log-line debug-log POST to the supervisor; off by default
59+
TRIGGER_SEND_RUN_DEBUG_LOGS: BoolEnv.default(false),
5060
});
5161

5262
type Env = z.infer<typeof Env>;
@@ -136,6 +146,9 @@ export class RunnerEnv {
136146
get TRIGGER_FAILURE_EXIT_CODE() {
137147
return this.env.TRIGGER_FAILURE_EXIT_CODE;
138148
}
149+
get TRIGGER_SEND_RUN_DEBUG_LOGS() {
150+
return this.env.TRIGGER_SEND_RUN_DEBUG_LOGS;
151+
}
139152
get TRIGGER_HEARTBEAT_INTERVAL_SECONDS() {
140153
return this.env.TRIGGER_HEARTBEAT_INTERVAL_SECONDS;
141154
}

packages/cli-v3/src/entryPoints/managed/logger.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export class ManagedRunLogger implements RunLogger {
5555
this.logger.log(message, mergedProperties);
5656
}
5757

58+
// Skip the per-log-line POST to the supervisor unless explicitly enabled
59+
if (!this.env.TRIGGER_SEND_RUN_DEBUG_LOGS) {
60+
return;
61+
}
62+
5863
const flattenedProperties = flattenAttributes(
5964
mergedProperties
6065
) satisfies WorkloadDebugLogRequestBody["properties"];

0 commit comments

Comments
 (0)