mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Trace remote exec-server connection setup (#35275)
## What changed - Preserve the current tracing span and subscriber when lazy remote environment startup runs in a background task. - Add spans for the remote connection, environment registry, Noise, and rendezvous WebSocket stages, including relevant environment and registration identifiers. - Propagate the current trace context to environment registry connection and harness-key validation requests. GitOrigin-RevId: 0044c3eb94d59c6a6b92752d3d372195be4adb81
This commit is contained in:
committed by
copyberry
parent
25b6fc9bbc
commit
c3e926e61c
@@ -337,11 +337,15 @@ impl LazyRemoteExecServerClient {
|
||||
return None;
|
||||
}
|
||||
let client = self.clone();
|
||||
Some(AbortOnDropHandle::new(tokio::spawn(async move {
|
||||
if let Err(error) = client.wait_until_ready().await {
|
||||
debug!(%error, "exec-server environment startup failed");
|
||||
Some(AbortOnDropHandle::new(tokio::spawn(
|
||||
async move {
|
||||
if let Err(error) = client.wait_until_ready().await {
|
||||
debug!(%error, "exec-server environment startup failed");
|
||||
}
|
||||
}
|
||||
})))
|
||||
.in_current_span()
|
||||
.with_current_subscriber(),
|
||||
)))
|
||||
}
|
||||
|
||||
pub(crate) fn startup_finished(&self) -> bool {
|
||||
@@ -509,6 +513,7 @@ impl LazyRemoteExecServerClient {
|
||||
)
|
||||
}
|
||||
|
||||
#[tracing::instrument(name = "codex.exec_server.remote.connect", skip_all)]
|
||||
async fn connect_once(&self) -> ConnectionResult {
|
||||
let result = ExecServerClient::connect_for_transport(
|
||||
self.transport_params.clone(),
|
||||
|
||||
@@ -170,6 +170,7 @@ impl ExecServerClient {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tracing::instrument(name = "codex.exec_server.remote.noise.connect", skip_all)]
|
||||
async fn open_initial_noise_rendezvous_connection(
|
||||
provider: &Arc<dyn NoiseRendezvousConnectProvider>,
|
||||
identity: &NoiseChannelIdentity,
|
||||
@@ -285,6 +286,16 @@ impl ExecServerClient {
|
||||
Self::connect(connection, options).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(
|
||||
name = "codex.exec_server.remote.noise.websocket_connect",
|
||||
skip_all,
|
||||
fields(
|
||||
otel.kind = "client",
|
||||
otel.name = "codex.exec_server.remote.noise.websocket_connect",
|
||||
environment_id = %args.bundle.environment_id,
|
||||
executor_registration_id = %args.bundle.executor_registration_id,
|
||||
)
|
||||
)]
|
||||
pub(crate) async fn open_noise_rendezvous_connection(
|
||||
args: NoiseRendezvousConnectArgs,
|
||||
) -> Result<(JsonRpcConnection, ExecServerClientConnectOptions), ExecServerError> {
|
||||
|
||||
@@ -170,6 +170,15 @@ impl EnvironmentRegistryClient {
|
||||
}
|
||||
|
||||
/// Authorize one Noise harness key and obtain the full rendezvous bundle.
|
||||
#[tracing::instrument(
|
||||
name = "codex.exec_server.remote.environment_registry.connect",
|
||||
skip_all,
|
||||
fields(
|
||||
otel.kind = "client",
|
||||
otel.name = "codex.exec_server.remote.environment_registry.connect",
|
||||
environment_id = %environment_id,
|
||||
)
|
||||
)]
|
||||
async fn connect_environment(
|
||||
&self,
|
||||
environment_id: &str,
|
||||
@@ -182,6 +191,7 @@ impl EnvironmentRegistryClient {
|
||||
&format!("/cloud/environment/{environment_id}/connect"),
|
||||
))
|
||||
.headers(self.auth_provider.to_auth_headers())
|
||||
.headers(current_trace_context_headers())
|
||||
.json(&EnvironmentRegistryConnectRequest { harness_public_key })
|
||||
.timeout(self.connect_timeout)
|
||||
.send()
|
||||
@@ -248,6 +258,16 @@ impl HarnessKeyValidator for RegistryHarnessKeyValidator {
|
||||
/// Authorize the harness key recovered from the first IK message.
|
||||
/// Noise proves key possession; the registry decides whether that key may use
|
||||
/// this executor. The authorization token and public key are checked together.
|
||||
#[tracing::instrument(
|
||||
name = "codex.exec_server.remote.environment_registry.validate_harness_key",
|
||||
skip_all,
|
||||
fields(
|
||||
otel.kind = "client",
|
||||
otel.name = "codex.exec_server.remote.environment_registry.validate_harness_key",
|
||||
environment_id = %self.environment_id,
|
||||
executor_registration_id = %self.executor_registration_id,
|
||||
)
|
||||
)]
|
||||
async fn validate_harness_key(
|
||||
&self,
|
||||
harness_public_key: &NoiseChannelPublicKey,
|
||||
@@ -262,6 +282,7 @@ impl HarnessKeyValidator for RegistryHarnessKeyValidator {
|
||||
&format!("/cloud/environment/{environment_id}/validate"),
|
||||
))
|
||||
.headers(self.client.auth_provider.to_auth_headers())
|
||||
.headers(current_trace_context_headers())
|
||||
.json(&EnvironmentRegistryHarnessKeyValidationRequest {
|
||||
executor_registration_id: self.executor_registration_id.clone(),
|
||||
harness_public_key: harness_public_key.clone(),
|
||||
|
||||
Reference in New Issue
Block a user