File tree 3 files changed +23
-10
lines changed
3 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -70,26 +70,29 @@ impl SpanExporter for OtlpHttpClient {
70
70
71
71
#[ cfg( any( feature = "http-proto" , feature = "http-json" ) ) ]
72
72
fn build_body ( spans : Vec < SpanData > ) -> TraceResult < ( Vec < u8 > , & ' static str ) > {
73
+ use crate :: exporter:: default_protocol;
74
+ #[ cfg( feature = "http-json" ) ]
75
+ use crate :: Protocol ;
73
76
use opentelemetry_proto:: tonic:: collector:: trace:: v1:: ExportTraceServiceRequest ;
77
+ #[ cfg( feature = "http-proto" ) ]
74
78
use prost:: Message ;
75
79
76
- use crate :: { exporter:: default_protocol, Protocol } ;
77
-
78
80
let req = ExportTraceServiceRequest {
79
81
resource_spans : spans. into_iter ( ) . map ( Into :: into) . collect ( ) ,
80
82
} ;
81
83
let buf;
82
84
let ctype;
83
85
match default_protocol ( ) {
86
+ #[ cfg( feature = "http-json" ) ]
84
87
Protocol :: HttpJson => {
85
88
let json_struct = serde_json:: to_string_pretty ( & req) . unwrap ( ) ;
86
89
buf = json_struct. into ( ) ;
87
- ctype = "application/json" ;
88
- } ,
90
+ ctype = "application/json" ;
91
+ }
89
92
_ => {
90
93
buf = req. encode_to_vec ( ) ;
91
- ctype = "application/x-protobuf" ;
92
- } ,
94
+ ctype = "application/x-protobuf" ;
95
+ }
93
96
} ;
94
97
Ok ( ( buf, ctype) )
95
98
}
Original file line number Diff line number Diff line change @@ -28,13 +28,20 @@ pub const OTEL_EXPORTER_OTLP_PROTOCOL: &str = "OTEL_EXPORTER_OTLP_PROTOCOL";
28
28
/// Compression algorithm to use, defaults to none.
29
29
pub const OTEL_EXPORTER_OTLP_COMPRESSION : & str = "OTEL_EXPORTER_OTLP_COMPRESSION" ;
30
30
31
- #[ cfg( all( feature = "trace" , not( feature = "http-proto" ) , not( feature = "grpc-tonic" ) ) ) ]
31
+ #[ cfg( all(
32
+ feature = "trace" ,
33
+ not( feature = "http-proto" ) ,
34
+ not( feature = "grpc-tonic" )
35
+ ) ) ]
32
36
/// Default protocol, using http-json.
33
37
pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON ;
34
38
#[ cfg( feature = "http-proto" ) ]
35
39
/// Default protocol, using http-proto.
36
40
pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF ;
37
- #[ cfg( all( feature = "grpc-tonic" , not( all( feature = "http-proto" , feature = "http-json" ) ) ) ) ]
41
+ #[ cfg( all(
42
+ feature = "grpc-tonic" ,
43
+ not( all( feature = "http-proto" , feature = "http-json" ) )
44
+ ) ) ]
38
45
/// Default protocol, using grpc as http-proto or http-json feature is not enabled.
39
46
pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT : & str = OTEL_EXPORTER_OTLP_PROTOCOL_GRPC ;
40
47
#[ cfg( not( any( any( feature = "grpc-tonic" , feature = "http-proto" , feature = "http-json" ) ) ) ) ]
Original file line number Diff line number Diff line change @@ -352,10 +352,13 @@ pub enum Error {
352
352
InvalidHeaderName ( #[ from] http:: header:: InvalidHeaderName ) ,
353
353
354
354
/// Prost encode failed
355
- #[ cfg( any( feature = "http-proto" , all( feature = "http-json" , not( feature = "trace" ) ) ) ) ]
355
+ #[ cfg( any(
356
+ feature = "http-proto" ,
357
+ all( feature = "http-json" , not( feature = "trace" ) )
358
+ ) ) ]
356
359
#[ error( "prost encoding error {0}" ) ]
357
360
EncodeError ( #[ from] prost:: EncodeError ) ,
358
-
361
+
359
362
/// The lock in exporters has been poisoned.
360
363
#[ cfg( feature = "metrics" ) ]
361
364
#[ error( "the lock of the {0} has been poisoned" ) ]
You can’t perform that action at this time.
0 commit comments