Skip to content
Open
Changes from 1 commit
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
24 changes: 24 additions & 0 deletions opentelemetry-otlp/src/exporter/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ impl HttpExporterBuilder {
.unwrap(), // TODO: Return ExporterBuildError::ThreadSpawnFailed
) as Arc<dyn HttpClient>);
}
#[cfg(any(
all(feature = "hyper-client", feature = "reqwest-client"),
all(feature = "hyper-client", feature = "reqwest-blocking-client"),
all(feature = "reqwest-client", feature = "reqwest-blocking-client")
))]
{
panic!("Can't enable more than one HTTP client features simultaneously. Please choose only one: hyper-client, reqwest-client, or reqwest-blocking-client (default feature)");
}
}

let http_client = http_client.ok_or(ExporterBuildError::NoHttpClient)?;
Expand Down Expand Up @@ -741,4 +749,20 @@ mod tests {
assert_eq!(url, "http://localhost:4318/v1/tracesbutnotreally");
});
}

#[cfg(any(
all(feature = "hyper-client", feature = "reqwest-client"),
all(feature = "hyper-client", feature = "reqwest-blocking-client"),
all(feature = "reqwest-client", feature = "reqwest-blocking-client")
))]
#[test]
#[should_panic(expected = "Can't enable more than one HTTP client features simultaneously.")]
fn test_http_exporter_builder_panics_with_multiple_http_features() {
let mut builder = HttpExporterBuilder {
http_config: HttpConfig::default(),
exporter_config: crate::ExportConfig::default(),
};

let _ = builder.build_client("ENV_VAR_1", "PATH", "ENV_VAR_2", "ENV_VAR_3");
}
}