@@ -33,12 +33,20 @@ mod logs;
33
33
#[ cfg( feature = "trace" ) ]
34
34
mod trace;
35
35
36
+ #[ cfg( all(
37
+ not( feature = "reqwest-client" ) ,
38
+ not( feature = "reqwest-blocking-client" ) ,
39
+ feature = "hyper-client"
40
+ ) ) ]
41
+ use opentelemetry_http:: hyper:: HyperClient ;
42
+
36
43
/// Configuration of the http transport
37
44
#[ derive( Debug ) ]
38
45
#[ cfg_attr(
39
46
all(
40
47
not( feature = "reqwest-client" ) ,
41
- not( feature = "reqwest-blocking-client" )
48
+ not( feature = "reqwest-blocking-client" ) ,
49
+ not( feature = "hyper-client" )
42
50
) ,
43
51
derive( Default )
44
52
) ]
@@ -50,19 +58,36 @@ pub struct HttpConfig {
50
58
headers : Option < HashMap < String , String > > ,
51
59
}
52
60
53
- #[ cfg( any( feature = "reqwest-blocking-client" , feature = "reqwest-client" , ) ) ]
61
+ #[ cfg( any(
62
+ feature = "reqwest-blocking-client" ,
63
+ feature = "reqwest-client" ,
64
+ feature = "hyper-client"
65
+ ) ) ]
54
66
impl Default for HttpConfig {
55
67
fn default ( ) -> Self {
68
+ #[ cfg( feature = "reqwest-blocking-client" ) ]
69
+ let default_client =
70
+ Some ( Arc :: new ( reqwest:: blocking:: Client :: new ( ) ) as Arc < dyn HttpClient > ) ;
71
+ #[ cfg( all( not( feature = "reqwest-blocking-client" ) , feature = "reqwest-client" ) ) ]
72
+ let default_client = Some ( Arc :: new ( reqwest:: Client :: new ( ) ) as Arc < dyn HttpClient > ) ;
73
+ #[ cfg( all(
74
+ not( feature = "reqwest-client" ) ,
75
+ not( feature = "reqwest-blocking-client" ) ,
76
+ feature = "hyper-client"
77
+ ) ) ]
78
+ // TODO - support configuring custom connector and executor
79
+ let default_client = Some ( Arc :: new ( HyperClient :: with_default_connector (
80
+ Duration :: from_secs ( 10 ) ,
81
+ None ,
82
+ ) ) as Arc < dyn HttpClient > ) ;
83
+ #[ cfg( all(
84
+ not( feature = "reqwest-client" ) ,
85
+ not( feature = "reqwest-blocking-client" ) ,
86
+ not( feature = "hyper-client" )
87
+ ) ) ]
88
+ let default_client = None ;
56
89
HttpConfig {
57
- #[ cfg( feature = "reqwest-blocking-client" ) ]
58
- client : Some ( Arc :: new ( reqwest:: blocking:: Client :: new ( ) ) ) ,
59
- #[ cfg( all( not( feature = "reqwest-blocking-client" ) , feature = "reqwest-client" ) ) ]
60
- client : Some ( Arc :: new ( reqwest:: Client :: new ( ) ) ) ,
61
- #[ cfg( all(
62
- not( feature = "reqwest-client" ) ,
63
- not( feature = "reqwest-blocking-client" )
64
- ) ) ]
65
- client : None ,
90
+ client : default_client,
66
91
headers : None ,
67
92
}
68
93
}
@@ -140,13 +165,11 @@ impl HttpExporterBuilder {
140
165
} ,
141
166
None => self . exporter_config . timeout ,
142
167
} ;
143
-
144
168
let http_client = self
145
169
. http_config
146
170
. client
147
171
. take ( )
148
172
. ok_or ( crate :: Error :: NoHttpClient ) ?;
149
-
150
173
#[ allow( clippy:: mutable_key_type) ] // http headers are not mutated
151
174
let mut headers: HashMap < HeaderName , HeaderValue > = self
152
175
. http_config
0 commit comments