Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/runner-send-debug-logs-gate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Runner debug logs are now disabled by default. Set `SEND_RUN_DEBUG_LOGS=true` on the supervisor to re-enable them.
1 change: 1 addition & 0 deletions apps/supervisor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class ManagedSupervisor {
instanceName: env.TRIGGER_WORKER_INSTANCE_NAME,
otelEndpoint: env.OTEL_EXPORTER_OTLP_ENDPOINT,
prettyLogs: env.RUNNER_PRETTY_LOGS,
sendRunDebugLogs: env.SEND_RUN_DEBUG_LOGS,
},
createRetry: {
maxAttempts: env.COMPUTE_INSTANCE_CREATE_MAX_ATTEMPTS,
Expand Down
2 changes: 2 additions & 0 deletions apps/supervisor/src/workloadManager/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type ComputeWorkloadManagerOptions = WorkloadManagerOptions & {
instanceName: string;
otelEndpoint: string;
prettyLogs: boolean;
sendRunDebugLogs: boolean;
};
createRetry?: {
maxAttempts: number;
Expand Down Expand Up @@ -162,6 +163,7 @@ export class ComputeWorkloadManager implements WorkloadManager {
TRIGGER_MACHINE_CPU: String(opts.machine.cpu),
TRIGGER_MACHINE_MEMORY: String(opts.machine.memory),
PRETTY_LOGS: String(this.opts.runner.prettyLogs),
TRIGGER_SEND_RUN_DEBUG_LOGS: String(this.opts.runner.sendRunDebugLogs),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
};

if (this.opts.warmStartUrl) {
Expand Down
1 change: 1 addition & 0 deletions apps/supervisor/src/workloadManager/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class DockerWorkloadManager implements WorkloadManager {
`TRIGGER_MACHINE_CPU=${opts.machine.cpu}`,
`TRIGGER_MACHINE_MEMORY=${opts.machine.memory}`,
`PRETTY_LOGS=${env.RUNNER_PRETTY_LOGS}`,
`TRIGGER_SEND_RUN_DEBUG_LOGS=${env.SEND_RUN_DEBUG_LOGS}`,
];

if (this.opts.warmStartUrl) {
Expand Down
4 changes: 4 additions & 0 deletions apps/supervisor/src/workloadManager/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ export class KubernetesWorkloadManager implements WorkloadManager {
name: "TRIGGER_MACHINE_MEMORY",
value: `${opts.machine.memory}`,
},
{
name: "TRIGGER_SEND_RUN_DEBUG_LOGS",
value: `${env.SEND_RUN_DEBUG_LOGS}`,
},
{
name: "LIMITS_CPU",
valueFrom: {
Expand Down
13 changes: 13 additions & 0 deletions packages/cli-v3/src/entryPoints/managed/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const DateEnv = z
.transform((val) => new Date(parseInt(val, 10)))
.pipe(z.date());

const BoolEnv = z.preprocess((val) => {
if (typeof val !== "string") {
return val;
}
return ["true", "1"].includes(val.toLowerCase().trim());
}, z.boolean());

// All IDs are friendly IDs
const Env = z.object({
// Set at build time
Expand Down Expand Up @@ -47,6 +54,9 @@ const Env = z.object({
TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS: z.coerce.number().default(5),
TRIGGER_SUCCESS_EXIT_CODE: z.coerce.number().default(0),
TRIGGER_FAILURE_EXIT_CODE: z.coerce.number().default(1),

// Gates the per-log-line debug-log POST to the supervisor; off by default
TRIGGER_SEND_RUN_DEBUG_LOGS: BoolEnv.default(false),
});

type Env = z.infer<typeof Env>;
Expand Down Expand Up @@ -136,6 +146,9 @@ export class RunnerEnv {
get TRIGGER_FAILURE_EXIT_CODE() {
return this.env.TRIGGER_FAILURE_EXIT_CODE;
}
get TRIGGER_SEND_RUN_DEBUG_LOGS() {
return this.env.TRIGGER_SEND_RUN_DEBUG_LOGS;
}
get TRIGGER_HEARTBEAT_INTERVAL_SECONDS() {
return this.env.TRIGGER_HEARTBEAT_INTERVAL_SECONDS;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/cli-v3/src/entryPoints/managed/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export class ManagedRunLogger implements RunLogger {
this.logger.log(message, mergedProperties);
}

// Skip the per-log-line POST to the supervisor unless explicitly enabled
if (!this.env.TRIGGER_SEND_RUN_DEBUG_LOGS) {
return;
}

const flattenedProperties = flattenAttributes(
mergedProperties
) satisfies WorkloadDebugLogRequestBody["properties"];
Expand Down
Loading