Skip to content

Commit 7fae10d

Browse files
committed
v3: make sure force flush timeout is set so flushing doesn’t hang forever
1 parent 8cf1f0a commit 7fae10d

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

packages/cli-v3/src/workers/dev/worker-setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const tracingSDK = new TracingSDK({
1818
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://0.0.0.0:4318",
1919
instrumentations: setupImportedConfig?.instrumentations ?? [],
2020
diagLogLevel: (process.env.OTEL_LOG_LEVEL as TracingDiagnosticLogLevel) ?? "none",
21+
forceFlushTimeoutMillis: 5_000,
2122
});
2223

2324
export const otelTracer: Tracer = tracingSDK.getTracer("trigger-dev-worker", packageJson.version);

packages/cli-v3/src/workers/prod/worker-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const tracingSDK = new TracingSDK({
1818
diagLogLevel: (process.env.OTEL_LOG_LEVEL as TracingDiagnosticLogLevel) ?? "none",
1919
forceFlushTimeoutMillis: process.env.OTEL_FORCE_FLUSH_TIMEOUT
2020
? parseInt(process.env.OTEL_FORCE_FLUSH_TIMEOUT, 10)
21-
: undefined,
21+
: 5_000,
2222
});
2323

2424
export const otelTracer: Tracer = tracingSDK.getTracer("trigger-prod-worker", packageJson.version);

packages/core/src/v3/otel/tracingSDK.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,11 @@ export class TracingSDK {
197197
}
198198

199199
public async flush() {
200-
await this._traceProvider.forceFlush();
201-
await this._logProvider.forceFlush();
200+
await Promise.all([this._traceProvider.forceFlush(), this._logProvider.forceFlush()]);
202201
}
203202

204203
public async shutdown() {
205-
await this._traceProvider.shutdown();
206-
await this._logProvider.shutdown();
204+
await Promise.all([this._traceProvider.shutdown(), this._logProvider.shutdown()]);
207205
}
208206
}
209207

0 commit comments

Comments
 (0)