@@ -33,12 +33,20 @@ mod logs;
3333#[ cfg( feature = "trace" ) ]
3434mod trace;
3535
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+
3643/// Configuration of the http transport
3744#[ derive( Debug ) ]
3845#[ cfg_attr(
3946 all(
4047 not( feature = "reqwest-client" ) ,
41- not( feature = "reqwest-blocking-client" )
48+ not( feature = "reqwest-blocking-client" ) ,
49+ not( feature = "hyper-client" )
4250 ) ,
4351 derive( Default )
4452) ]
@@ -50,19 +58,36 @@ pub struct HttpConfig {
5058 headers : Option < HashMap < String , String > > ,
5159}
5260
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+ ) ) ]
5466impl Default for HttpConfig {
5567 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 ;
5689 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,
6691 headers : None ,
6792 }
6893 }
@@ -140,13 +165,11 @@ impl HttpExporterBuilder {
140165 } ,
141166 None => self . exporter_config . timeout ,
142167 } ;
143-
144168 let http_client = self
145169 . http_config
146170 . client
147171 . take ( )
148172 . ok_or ( crate :: Error :: NoHttpClient ) ?;
149-
150173 #[ allow( clippy:: mutable_key_type) ] // http headers are not mutated
151174 let mut headers: HashMap < HeaderName , HeaderValue > = self
152175 . http_config
0 commit comments