Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions opentelemetry-otlp/src/exporter/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ impl<B: HasHttpConfig> WithHttpConfig for B {

fn with_headers(mut self, headers: HashMap<String, String>) -> Self {
// headers will be wrapped, so we must do some logic to unwrap first.
self.http_client_config()
let http_client_headers = self
.http_client_config()
.headers
.iter_mut()
.zip(headers)
.for_each(|(http_client_headers, (key, value))| {
http_client_headers.insert(key, super::url_decode(&value).unwrap_or(value));
});
.get_or_insert(HashMap::new());
headers.into_iter().for_each(|(key, value)| {
http_client_headers.insert(key, super::url_decode(&value).unwrap_or(value));
});
self
}
}
Expand Down Expand Up @@ -671,11 +671,14 @@ mod tests {
}

#[test]
fn test_http_exporter_builder_with_header() {
fn test_http_exporter_builder_with_headers() {
use std::collections::HashMap;
// Arrange
let initial_headers = HashMap::from([("k1".to_string(), "v1".to_string())]);
let extra_headers = HashMap::from([("k2".to_string(), "v2".to_string())]);
let extra_headers = HashMap::from([
("k2".to_string(), "v2".to_string()),
("k3".to_string(), "v3".to_string()),
]);
let expected_headers = initial_headers.iter().chain(extra_headers.iter()).fold(
HashMap::new(),
|mut acc, (k, v)| {
Expand Down