mirror of
https://github.com/openai/codex.git
synced 2026-08-25 13:28:55 +00:00
## What changed - Add `x-cluster-name` from `OPENAI_CLUSTER` and `x-openai-internal-caller` from `DD_SERVICE` to rendezvous WebSocket handshakes when the environment values are nonempty and valid HTTP header values. - Apply the rendezvous headers to both client and remote executor connections while preserving the existing W3C trace context headers. GitOrigin-RevId: fead0244ba24fa208990b92d2170a9ae76ff2ceb
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use http::HeaderMap;
|
|
use http::HeaderValue;
|
|
|
|
pub(crate) fn current_rendezvous_headers() -> HeaderMap {
|
|
let mut headers = current_trace_context_headers();
|
|
for (header, variable) in [
|
|
("x-cluster-name", "OPENAI_CLUSTER"),
|
|
("x-openai-internal-caller", "DD_SERVICE"),
|
|
] {
|
|
if let Ok(value) = std::env::var(variable)
|
|
&& !value.is_empty()
|
|
&& let Ok(value) = HeaderValue::try_from(value)
|
|
{
|
|
headers.insert(header, value);
|
|
}
|
|
}
|
|
headers
|
|
}
|
|
|
|
pub(crate) fn current_trace_context_headers() -> HeaderMap {
|
|
let mut headers = HeaderMap::new();
|
|
let Some(trace) = codex_otel::current_span_w3c_trace_context() else {
|
|
return headers;
|
|
};
|
|
if let Some(traceparent) = trace.traceparent
|
|
&& let Ok(value) = HeaderValue::try_from(traceparent)
|
|
{
|
|
headers.insert("traceparent", value);
|
|
}
|
|
if let Some(tracestate) = trace.tracestate
|
|
&& let Ok(value) = HeaderValue::try_from(tracestate)
|
|
{
|
|
headers.insert("tracestate", value);
|
|
}
|
|
headers
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "trace_context_tests.rs"]
|
|
mod tests;
|