Prepare the telemetry shutdown worker during initialization (#39050)

## Why

Creating the telemetry shutdown thread during shutdown can fail under resource
pressure, including when the native thread guard page cannot be allocated.

## What changed

- Start and verify a dedicated shutdown worker when `OtelProvider` is created.
- Send the provider to the prepared worker for bounded shutdown, while preserving
  timeout behavior and avoiding a potentially blocking destructor if worker
  preparation failed.
- Rename the fallible provider constructor to `try_new`.

## Testing

Add Unix regression coverage that injects guard-page allocation failures, plus
coverage for worker preparation failure, successful shutdown, and timeouts.

GitOrigin-RevId: 3656298078a800a7fa392437c2ee4a68753092e3
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-08-17 19:06:53 +00:00
1 parent 1a8bac9405
commit d7d526b81d
8 files changed
+323 -46

No files matched your search

+1 -1
View File
@@ -46,7 +46,7 @@ fn build_wfp_metrics_provider(
// depends on this crate, so the parent process passes only the resolved
// Statsig environment in the elevation payload. Other exporters are
// intentionally omitted from this helper path.
OtelProvider::from(&OtelSettings {
OtelProvider::try_new(&OtelSettings {
environment: otel.environment.clone(),
service_name: WFP_SETUP_SERVICE_NAME.to_string(),
service_version: env!("CARGO_PKG_VERSION").to_string(),