11use super :: {
2- default_headers, default_protocol , parse_header_string, resolve_timeout, ExporterBuildError ,
2+ default_headers, parse_header_string, resolve_timeout, ExporterBuildError ,
33 OTEL_EXPORTER_OTLP_HTTP_ENDPOINT_DEFAULT ,
44} ;
55use crate :: { ExportConfig , Protocol , OTEL_EXPORTER_OTLP_ENDPOINT , OTEL_EXPORTER_OTLP_HEADERS } ;
@@ -15,6 +15,7 @@ use opentelemetry_proto::transform::trace::tonic::group_spans_by_resource_and_sc
1515use opentelemetry_sdk:: logs:: LogBatch ;
1616#[ cfg( feature = "trace" ) ]
1717use opentelemetry_sdk:: trace:: SpanData ;
18+ #[ cfg( feature = "http-proto" ) ]
1819use prost:: Message ;
1920use std:: collections:: HashMap ;
2021use std:: env;
@@ -154,7 +155,7 @@ impl Default for HttpExporterBuilder {
154155 fn default ( ) -> Self {
155156 HttpExporterBuilder {
156157 exporter_config : ExportConfig {
157- protocol : default_protocol ( ) ,
158+ protocol : Protocol :: default ( ) ,
158159 ..ExportConfig :: default ( )
159160 } ,
160161 http_config : HttpConfig {
@@ -595,7 +596,12 @@ impl OtlpHttpClient {
595596 Ok ( json) => ( json. into_bytes ( ) , "application/json" ) ,
596597 Err ( e) => return Err ( e. to_string ( ) ) ,
597598 } ,
598- _ => ( req. encode_to_vec ( ) , "application/x-protobuf" ) ,
599+ #[ cfg( feature = "http-proto" ) ]
600+ Protocol :: HttpBinary => ( req. encode_to_vec ( ) , "application/x-protobuf" ) ,
601+ #[ cfg( feature = "grpc-tonic" ) ]
602+ Protocol :: Grpc => {
603+ unreachable ! ( "HTTP client should not receive Grpc protocol" )
604+ }
599605 } ;
600606
601607 let ( processed_body, content_encoding) = self . process_body ( body) ?;
@@ -617,7 +623,12 @@ impl OtlpHttpClient {
617623 Ok ( json) => ( json. into_bytes ( ) , "application/json" ) ,
618624 Err ( e) => return Err ( e. to_string ( ) ) ,
619625 } ,
620- _ => ( req. encode_to_vec ( ) , "application/x-protobuf" ) ,
626+ #[ cfg( feature = "http-proto" ) ]
627+ Protocol :: HttpBinary => ( req. encode_to_vec ( ) , "application/x-protobuf" ) ,
628+ #[ cfg( feature = "grpc-tonic" ) ]
629+ Protocol :: Grpc => {
630+ unreachable ! ( "HTTP client should not receive Grpc protocol" )
631+ }
621632 } ;
622633
623634 let ( processed_body, content_encoding) = self . process_body ( body) ?;
@@ -642,7 +653,12 @@ impl OtlpHttpClient {
642653 return None ;
643654 }
644655 } ,
645- _ => ( req. encode_to_vec ( ) , "application/x-protobuf" ) ,
656+ #[ cfg( feature = "http-proto" ) ]
657+ Protocol :: HttpBinary => ( req. encode_to_vec ( ) , "application/x-protobuf" ) ,
658+ #[ cfg( feature = "grpc-tonic" ) ]
659+ Protocol :: Grpc => {
660+ unreachable ! ( "HTTP client should not receive Grpc protocol" )
661+ }
646662 } ;
647663
648664 match self . process_body ( body) {
0 commit comments