mirror of
https://github.com/openai/codex.git
synced 2026-11-23 15:18:14 +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:
1 parent
25b6fc9bbc
commit
c3e926e61c
3 files changed
+41
-4
No files matched your search
@@ -337,11 +337,15 @@ impl LazyRemoteExecServerClient {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let client = self.clone();
|
let client = self.clone();
|
||||||
Some(AbortOnDropHandle::new(tokio::spawn(async move {
|
Some(AbortOnDropHandle::new(tokio::spawn(
|
||||||
if let Err(error) = client.wait_until_ready().await {
|
async move {
|
||||||
debug!(%error, "exec-server environment startup failed");
|
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 {
|
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 {
|
async fn connect_once(&self) -> ConnectionResult {
|
||||||
let result = ExecServerClient::connect_for_transport(
|
let result = ExecServerClient::connect_for_transport(
|
||||||
self.transport_params.clone(),
|
self.transport_params.clone(),
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ impl ExecServerClient {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(name = "codex.exec_server.remote.noise.connect", skip_all)]
|
||||||
async fn open_initial_noise_rendezvous_connection(
|
async fn open_initial_noise_rendezvous_connection(
|
||||||
provider: &Arc<dyn NoiseRendezvousConnectProvider>,
|
provider: &Arc<dyn NoiseRendezvousConnectProvider>,
|
||||||
identity: &NoiseChannelIdentity,
|
identity: &NoiseChannelIdentity,
|
||||||
@@ -285,6 +286,16 @@ impl ExecServerClient {
|
|||||||
Self::connect(connection, options).await
|
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(
|
pub(crate) async fn open_noise_rendezvous_connection(
|
||||||
args: NoiseRendezvousConnectArgs,
|
args: NoiseRendezvousConnectArgs,
|
||||||
) -> Result<(JsonRpcConnection, ExecServerClientConnectOptions), ExecServerError> {
|
) -> Result<(JsonRpcConnection, ExecServerClientConnectOptions), ExecServerError> {
|
||||||
|
|||||||
@@ -170,6 +170,15 @@ impl EnvironmentRegistryClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Authorize one Noise harness key and obtain the full rendezvous bundle.
|
/// 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(
|
async fn connect_environment(
|
||||||
&self,
|
&self,
|
||||||
environment_id: &str,
|
environment_id: &str,
|
||||||
@@ -182,6 +191,7 @@ impl EnvironmentRegistryClient {
|
|||||||
&format!("/cloud/environment/{environment_id}/connect"),
|
&format!("/cloud/environment/{environment_id}/connect"),
|
||||||
))
|
))
|
||||||
.headers(self.auth_provider.to_auth_headers())
|
.headers(self.auth_provider.to_auth_headers())
|
||||||
|
.headers(current_trace_context_headers())
|
||||||
.json(&EnvironmentRegistryConnectRequest { harness_public_key })
|
.json(&EnvironmentRegistryConnectRequest { harness_public_key })
|
||||||
.timeout(self.connect_timeout)
|
.timeout(self.connect_timeout)
|
||||||
.send()
|
.send()
|
||||||
@@ -248,6 +258,16 @@ impl HarnessKeyValidator for RegistryHarnessKeyValidator {
|
|||||||
/// Authorize the harness key recovered from the first IK message.
|
/// Authorize the harness key recovered from the first IK message.
|
||||||
/// Noise proves key possession; the registry decides whether that key may use
|
/// Noise proves key possession; the registry decides whether that key may use
|
||||||
/// this executor. The authorization token and public key are checked together.
|
/// 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(
|
async fn validate_harness_key(
|
||||||
&self,
|
&self,
|
||||||
harness_public_key: &NoiseChannelPublicKey,
|
harness_public_key: &NoiseChannelPublicKey,
|
||||||
@@ -262,6 +282,7 @@ impl HarnessKeyValidator for RegistryHarnessKeyValidator {
|
|||||||
&format!("/cloud/environment/{environment_id}/validate"),
|
&format!("/cloud/environment/{environment_id}/validate"),
|
||||||
))
|
))
|
||||||
.headers(self.client.auth_provider.to_auth_headers())
|
.headers(self.client.auth_provider.to_auth_headers())
|
||||||
|
.headers(current_trace_context_headers())
|
||||||
.json(&EnvironmentRegistryHarnessKeyValidationRequest {
|
.json(&EnvironmentRegistryHarnessKeyValidationRequest {
|
||||||
executor_registration_id: self.executor_registration_id.clone(),
|
executor_registration_id: self.executor_registration_id.clone(),
|
||||||
harness_public_key: harness_public_key.clone(),
|
harness_public_key: harness_public_key.clone(),
|
||||||
|
|||||||
Reference in new issue
Block a user