@@ -19,9 +19,7 @@ use tonic::transport::ClientTlsConfig;
1919use super :: { default_headers, parse_header_string, OTEL_EXPORTER_OTLP_GRPC_ENDPOINT_DEFAULT } ;
2020use super :: { resolve_timeout, ExporterBuildError } ;
2121use crate :: exporter:: Compression ;
22- use crate :: {
23- exporter:: ExportConfig , Protocol , OTEL_EXPORTER_OTLP_ENDPOINT , OTEL_EXPORTER_OTLP_HEADERS ,
24- } ;
22+ use crate :: { exporter:: ExportConfig , OTEL_EXPORTER_OTLP_ENDPOINT , OTEL_EXPORTER_OTLP_HEADERS } ;
2523
2624#[ cfg( all(
2725 feature = "experimental-grpc-retry" ,
@@ -209,18 +207,26 @@ impl TonicExporterBuilder {
209207 // Env var-based transport selection is handled at the auto-select layer
210208 // (e.g., SpanExporter::builder().build()), which routes to the correct
211209 // transport before reaching this code.
212- let protocol = super :: resolve_protocol ( signal_protocol_var, self . exporter_config . protocol ) ;
213-
214- let is_http_protocol = false ;
215- #[ cfg( feature = "http-proto" ) ]
216- let is_http_protocol = is_http_protocol || matches ! ( protocol, Protocol :: HttpBinary ) ;
217- #[ cfg( feature = "http-json" ) ]
218- let is_http_protocol = is_http_protocol || matches ! ( protocol, Protocol :: HttpJson ) ;
219- if is_http_protocol {
220- return Err ( ExporterBuildError :: InvalidConfig {
221- name : "protocol" . to_string ( ) ,
222- reason : "HTTP protocol is not compatible with gRPC transport. Use `.with_http()` instead." . to_string ( ) ,
223- } ) ;
210+ #[ cfg( any( feature = "grpc-tonic" , feature = "http-proto" , feature = "http-json" ) ) ]
211+ {
212+ let protocol =
213+ super :: resolve_protocol ( signal_protocol_var, self . exporter_config . protocol ) ;
214+
215+ let is_http_protocol = false ;
216+ #[ cfg( feature = "http-proto" ) ]
217+ let is_http_protocol =
218+ is_http_protocol || matches ! ( protocol, crate :: Protocol :: HttpBinary ) ;
219+ #[ cfg( feature = "http-json" ) ]
220+ let is_http_protocol =
221+ is_http_protocol || matches ! ( protocol, crate :: Protocol :: HttpJson ) ;
222+ if is_http_protocol {
223+ return Err ( ExporterBuildError :: InvalidConfig {
224+ name : "protocol" . to_string ( ) ,
225+ reason :
226+ "HTTP protocol is not compatible with gRPC transport. Use `.with_http()` instead."
227+ . to_string ( ) ,
228+ } ) ;
229+ }
224230 }
225231
226232 let compression = self . resolve_compression ( signal_compression_var) ?;
0 commit comments