diff --git a/src/lib.rs b/src/lib.rs index 466689739..317a0b4d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,6 +43,7 @@ pub use metrics::{ MaxLatencyMetric, MinLatencyMetric, P50LatencyMetric, P75LatencyMetric, P95LatencyMetric, P99LatencyMetric, rewrite_distributed_plan_with_metrics, }; +pub use passthrough_headers::get_passthrough_headers; pub use protocol::LocalWorkerContext; mod events; diff --git a/src/passthrough_headers.rs b/src/passthrough_headers.rs index d269e6851..42f94eb45 100644 --- a/src/passthrough_headers.rs +++ b/src/passthrough_headers.rs @@ -30,9 +30,20 @@ pub(crate) fn set_passthrough_headers( Ok(()) } -/// Gets passthrough headers from a SessionConfig extension. -/// Returns an empty HeaderMap if none are set. -pub(crate) fn get_passthrough_headers(cfg: &SessionConfig) -> HeaderMap { +/// Returns a copy of the worker passthrough headers, or an empty map if unset. +/// +/// Read, modify, then write the map to preserve other configured headers: +/// +/// ``` +/// # use datafusion::prelude::SessionConfig; +/// use datafusion_distributed::{DistributedExt, get_passthrough_headers}; +/// # let mut config = SessionConfig::new(); +/// let mut headers = get_passthrough_headers(&config); +/// headers.insert("x-query-context", "example".parse()?); +/// config.set_distributed_passthrough_headers(headers)?; +/// # Ok::<(), Box>(()) +/// ``` +pub fn get_passthrough_headers(cfg: &SessionConfig) -> HeaderMap { cfg.get_extension::() .map(|h| h.0.clone()) .unwrap_or_default()