@@ -29,27 +29,6 @@ pub const OTEL_EXPORTER_OTLP_PROTOCOL: &str = "OTEL_EXPORTER_OTLP_PROTOCOL";
2929/// Compression algorithm to use, defaults to none.
3030pub const OTEL_EXPORTER_OTLP_COMPRESSION : & str = "OTEL_EXPORTER_OTLP_COMPRESSION" ;
3131
32- #[ cfg( feature = "http-json" ) ]
33- /// Default protocol, using http-json.
34- pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON ;
35- #[ cfg( all( feature = "http-proto" , not( feature = "http-json" ) ) ) ]
36- /// Default protocol, using http-proto.
37- pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF ;
38- #[ cfg( all(
39- feature = "grpc-tonic" ,
40- not( any( feature = "http-proto" , feature = "http-json" ) )
41- ) ) ]
42- /// Default protocol, using grpc
43- pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = OTEL_EXPORTER_OTLP_PROTOCOL_GRPC ;
44-
45- #[ cfg( not( any( feature = "grpc-tonic" , feature = "http-proto" , feature = "http-json" ) ) ) ]
46- /// Default protocol if no features are enabled.
47- pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = "" ;
48-
49- const OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF : & str = "http/protobuf" ;
50- const OTEL_EXPORTER_OTLP_PROTOCOL_GRPC : & str = "grpc" ;
51- const OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON : & str = "http/json" ;
52-
5332/// Max waiting time for the backend to process each signal batch, defaults to 10 seconds.
5433pub const OTEL_EXPORTER_OTLP_TIMEOUT : & str = "OTEL_EXPORTER_OTLP_TIMEOUT" ;
5534/// Default max waiting time for the backend to process each signal batch.
@@ -84,6 +63,7 @@ pub struct ExportConfig {
8463 pub timeout : Option < Duration > ,
8564}
8665
66+ #[ cfg( any( feature = "grpc-tonic" , feature = "http-proto" , feature = "http-json" ) ) ]
8767impl Default for ExportConfig {
8868 fn default ( ) -> Self {
8969 let protocol = default_protocol ( ) ;
@@ -190,14 +170,22 @@ fn resolve_compression_from_env(
190170 }
191171}
192172
193- /// default protocol based on enabled features
173+ /// Returns the default protocol based on enabled features.
174+ ///
175+ /// Priority order (first available wins):
176+ /// 1. http-json (if enabled)
177+ /// 2. http-proto (if enabled)
178+ /// 3. grpc-tonic (if enabled)
179+ #[ cfg( any( feature = "grpc-tonic" , feature = "http-proto" , feature = "http-json" ) ) ]
194180fn default_protocol ( ) -> Protocol {
195- match OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT {
196- OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF => Protocol :: HttpBinary ,
197- OTEL_EXPORTER_OTLP_PROTOCOL_GRPC => Protocol :: Grpc ,
198- OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON => Protocol :: HttpJson ,
199- _ => Protocol :: HttpBinary ,
200- }
181+ #[ cfg( feature = "http-json" ) ]
182+ return Protocol :: HttpJson ;
183+
184+ #[ cfg( all( feature = "http-proto" , not( feature = "http-json" ) ) ) ]
185+ return Protocol :: HttpBinary ;
186+
187+ #[ cfg( all( feature = "grpc-tonic" , not( any( feature = "http-proto" , feature = "http-json" ) ) ) ) ]
188+ return Protocol :: Grpc ;
201189}
202190
203191/// default user-agent headers
0 commit comments