mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
fix(otel): initialize Rustls provider for gRPC exporters
This commit is contained in:
Generated
+1
-1
@@ -3394,7 +3394,6 @@ dependencies = [
|
||||
"codex-utils-absolute-path",
|
||||
"codex-utils-cli",
|
||||
"codex-utils-json-to-toml",
|
||||
"codex-utils-rustls-provider",
|
||||
"core_test_support",
|
||||
"mcp_test_support",
|
||||
"os_info",
|
||||
@@ -3615,6 +3614,7 @@ dependencies = [
|
||||
"codex-app-server-protocol",
|
||||
"codex-protocol",
|
||||
"codex-utils-absolute-path",
|
||||
"codex-utils-rustls-provider",
|
||||
"codex-utils-string",
|
||||
"eventsource-stream",
|
||||
"gethostname",
|
||||
|
||||
@@ -28,7 +28,6 @@ codex-login = { workspace = true }
|
||||
codex-protocol = { workspace = true }
|
||||
codex-utils-cli = { workspace = true }
|
||||
codex-utils-json-to-toml = { workspace = true }
|
||||
codex-utils-rustls-provider = { workspace = true }
|
||||
rmcp = { workspace = true }
|
||||
schemars = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
|
||||
@@ -12,7 +12,6 @@ use codex_exec_server::EnvironmentManager;
|
||||
use codex_exec_server::ExecServerRuntimePaths;
|
||||
use codex_login::default_client::set_default_client_residency_requirement;
|
||||
use codex_utils_cli::CliConfigOverrides;
|
||||
use codex_utils_rustls_provider::ensure_rustls_crypto_provider;
|
||||
|
||||
use rmcp::model::ClientNotification;
|
||||
use rmcp::model::ClientRequest;
|
||||
@@ -79,7 +78,6 @@ pub async fn run_main(
|
||||
std::io::Error::new(ErrorKind::InvalidData, format!("error loading config: {e}"))
|
||||
})?;
|
||||
set_default_client_residency_requirement(config.enforce_residency.value());
|
||||
ensure_rustls_crypto_provider();
|
||||
let otel = codex_core::otel_init::build_provider(
|
||||
&config,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
@@ -220,7 +218,6 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_server_builds_otel_provider_with_logs_traces_and_metrics() -> anyhow::Result<()> {
|
||||
ensure_rustls_crypto_provider();
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
|
||||
@@ -15,6 +15,7 @@ workspace = true
|
||||
[dependencies]
|
||||
chrono = { workspace = true }
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
codex-utils-rustls-provider = { workspace = true }
|
||||
codex-utils-string = { workspace = true }
|
||||
codex-api = { workspace = true }
|
||||
codex-app-server-protocol = { workspace = true }
|
||||
|
||||
@@ -38,7 +38,6 @@ use std::sync::Mutex;
|
||||
use std::sync::Weak;
|
||||
use std::time::Duration;
|
||||
use tonic::metadata::MetadataMap;
|
||||
use tonic::transport::ClientTlsConfig;
|
||||
use tracing::debug;
|
||||
|
||||
const ENV_ATTRIBUTE: &str = "env";
|
||||
@@ -476,9 +475,7 @@ fn build_otlp_metric_exporter(
|
||||
|
||||
let header_map = crate::otlp::build_header_map(&headers);
|
||||
|
||||
let base_tls_config = ClientTlsConfig::new()
|
||||
.with_enabled_roots()
|
||||
.assume_http2(true);
|
||||
let base_tls_config = crate::otlp::default_grpc_tls_config();
|
||||
|
||||
let tls_config = match tls.as_ref() {
|
||||
Some(tls) => crate::otlp::build_grpc_tls_config(&endpoint, base_tls_config, tls)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::config::OtelTlsConfig;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_rustls_provider::ensure_rustls_crypto_provider;
|
||||
use http::Uri;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT;
|
||||
@@ -31,6 +32,13 @@ pub(crate) fn build_header_map(headers: &std::collections::HashMap<String, Strin
|
||||
header_map
|
||||
}
|
||||
|
||||
pub(crate) fn default_grpc_tls_config() -> ClientTlsConfig {
|
||||
ensure_rustls_crypto_provider();
|
||||
ClientTlsConfig::new()
|
||||
.with_enabled_roots()
|
||||
.assume_http2(true)
|
||||
}
|
||||
|
||||
pub(crate) fn build_grpc_tls_config(
|
||||
endpoint: &str,
|
||||
tls_config: ClientTlsConfig,
|
||||
|
||||
@@ -38,7 +38,6 @@ use opentelemetry_semantic_conventions as semconv;
|
||||
use std::collections::BTreeMap;
|
||||
use std::error::Error;
|
||||
use tonic::metadata::MetadataMap;
|
||||
use tonic::transport::ClientTlsConfig;
|
||||
use tracing::debug;
|
||||
use tracing_subscriber::Layer;
|
||||
use tracing_subscriber::registry::LookupSpan;
|
||||
@@ -308,9 +307,7 @@ fn build_logger(
|
||||
|
||||
let header_map = crate::otlp::build_header_map(&headers);
|
||||
|
||||
let base_tls_config = ClientTlsConfig::new()
|
||||
.with_enabled_roots()
|
||||
.assume_http2(true);
|
||||
let base_tls_config = crate::otlp::default_grpc_tls_config();
|
||||
|
||||
let tls_config = match tls.as_ref() {
|
||||
Some(tls) => crate::otlp::build_grpc_tls_config(&endpoint, base_tls_config, tls)?,
|
||||
@@ -376,9 +373,7 @@ fn build_tracer_provider(
|
||||
|
||||
let header_map = crate::otlp::build_header_map(&headers);
|
||||
|
||||
let base_tls_config = ClientTlsConfig::new()
|
||||
.with_enabled_roots()
|
||||
.assume_http2(true);
|
||||
let base_tls_config = crate::otlp::default_grpc_tls_config();
|
||||
|
||||
let tls_config = match tls.as_ref() {
|
||||
Some(tls) => crate::otlp::build_grpc_tls_config(&endpoint, base_tls_config, tls)?,
|
||||
|
||||
Reference in New Issue
Block a user