mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
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:
1 parent
1a8bac9405
commit
d7d526b81d
8 files changed
+323
-46
No files matched your search
@@ -343,7 +343,7 @@ fn otlp_http_exporter_sends_logs_to_collector()
|
||||
let _ = tx.send(captured);
|
||||
});
|
||||
|
||||
let otel = OtelProvider::from(&OtelSettings {
|
||||
let otel = OtelProvider::try_new(&OtelSettings {
|
||||
environment: "test".to_string(),
|
||||
service_name: "codex-cli".to_string(),
|
||||
service_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
@@ -402,7 +402,7 @@ fn otlp_http_exporter_sends_logs_to_collector()
|
||||
|
||||
#[test]
|
||||
fn otel_provider_rejects_header_unsafe_configured_tracestate() {
|
||||
let result = OtelProvider::from(&OtelSettings {
|
||||
let result = OtelProvider::try_new(&OtelSettings {
|
||||
environment: "test".to_string(),
|
||||
service_name: "codex-cli".to_string(),
|
||||
service_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
@@ -467,7 +467,7 @@ fn otlp_http_exporter_sends_traces_to_collector()
|
||||
let _ = tx.send(captured);
|
||||
});
|
||||
|
||||
let otel = OtelProvider::from(&OtelSettings {
|
||||
let otel = OtelProvider::try_new(&OtelSettings {
|
||||
environment: "test".to_string(),
|
||||
service_name: "codex-cli".to_string(),
|
||||
service_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
@@ -612,7 +612,7 @@ async fn otlp_http_exporter_sends_traces_to_collector_with_bounded_shutdown_in_t
|
||||
let _ = tx.send(captured);
|
||||
});
|
||||
|
||||
let otel = OtelProvider::from(&OtelSettings {
|
||||
let otel = OtelProvider::try_new(&OtelSettings {
|
||||
environment: "test".to_string(),
|
||||
service_name: "codex-cli".to_string(),
|
||||
service_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
@@ -705,7 +705,7 @@ fn otlp_http_exporter_times_out_when_collector_stalls_during_bounded_shutdown()
|
||||
.build()
|
||||
.expect("build tokio runtime");
|
||||
let (result, elapsed) = runtime.block_on(async move {
|
||||
let otel = OtelProvider::from(&OtelSettings {
|
||||
let otel = OtelProvider::try_new(&OtelSettings {
|
||||
environment: "test".to_string(),
|
||||
service_name: "codex-cli".to_string(),
|
||||
service_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
@@ -804,7 +804,7 @@ fn otlp_http_exporter_sends_traces_to_collector_in_current_thread_tokio_runtime(
|
||||
.expect("current-thread runtime");
|
||||
|
||||
let result = runtime.block_on(async move {
|
||||
let otel = OtelProvider::from(&OtelSettings {
|
||||
let otel = OtelProvider::try_new(&OtelSettings {
|
||||
environment: "test".to_string(),
|
||||
service_name: "codex-cli".to_string(),
|
||||
service_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
|
||||
Reference in new issue
Block a user