@@ -91,15 +91,19 @@ pub struct ExportConfig {
91
91
pub timeout : Duration ,
92
92
93
93
/// Disable TLS
94
+ #[ cfg( feature = "tls" ) ]
94
95
pub insecure : Option < bool > ,
95
96
96
97
/// The certificate file to validate the OTLP server connection
98
+ #[ cfg( feature = "tls" ) ]
97
99
pub certificate : Option < String > ,
98
100
99
101
/// The path to the certificate file to use for client authentication (mTLS).
102
+ #[ cfg( feature = "tls" ) ]
100
103
pub client_certificate : Option < String > ,
101
104
102
105
/// The path to the key file to use for client authentication (mTLS).
106
+ #[ cfg( feature = "tls" ) ]
103
107
pub client_key : Option < String > ,
104
108
}
105
109
@@ -113,9 +117,13 @@ impl Default for ExportConfig {
113
117
// won't know if user provided a value
114
118
protocol,
115
119
timeout : Duration :: from_secs ( OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT ) ,
120
+ #[ cfg( feature = "tls" ) ]
116
121
insecure : None ,
122
+ #[ cfg( feature = "tls" ) ]
117
123
certificate : None ,
124
+ #[ cfg( feature = "tls" ) ]
118
125
client_certificate : None ,
126
+ #[ cfg( feature = "tls" ) ]
119
127
client_key : None ,
120
128
}
121
129
}
@@ -225,15 +233,19 @@ pub trait WithExportConfig {
225
233
/// Set export config. This will override all previous configuration.
226
234
fn with_export_config ( self , export_config : ExportConfig ) -> Self ;
227
235
/// Set insecure connection. Disable TLS
236
+ #[ cfg( feature = "tls" ) ]
228
237
fn with_insecure ( self ) -> Self ;
229
238
/// Set the certificate file to validate the OTLP server connection
230
239
/// This is only available when the `tls` feature is enabled.
240
+ #[ cfg( feature = "tls" ) ]
231
241
fn with_certificate < T : Into < String > > ( self , certificate : T ) -> Self ;
232
242
/// Set the path to the certificate file to use for client authentication (mTLS).
233
243
/// This is only available when the `tls` feature is enabled.
244
+ #[ cfg( feature = "tls" ) ]
234
245
fn with_client_certificate < T : Into < String > > ( self , client_certificate : T ) -> Self ;
235
246
/// Set the path to the key file to use for client authentication (mTLS).
236
247
/// This is only available when the `tls` feature is enabled.
248
+ #[ cfg( feature = "tls" ) ]
237
249
fn with_client_key < T : Into < String > > ( self , client_key : T ) -> Self ;
238
250
}
239
251
@@ -257,25 +269,32 @@ impl<B: HasExportConfig> WithExportConfig for B {
257
269
self . export_config ( ) . endpoint = exporter_config. endpoint ;
258
270
self . export_config ( ) . protocol = exporter_config. protocol ;
259
271
self . export_config ( ) . timeout = exporter_config. timeout ;
260
- self . export_config ( ) . insecure = Some ( true ) ;
272
+ #[ cfg( feature = "tls" ) ]
273
+ {
274
+ self . export_config ( ) . insecure = Some ( true ) ;
275
+ }
261
276
self
262
277
}
263
278
279
+ #[ cfg( feature = "tls" ) ]
264
280
fn with_insecure ( mut self ) -> Self {
265
281
self . export_config ( ) . insecure = Some ( true ) ;
266
282
self
267
283
}
268
284
285
+ #[ cfg( feature = "tls" ) ]
269
286
fn with_certificate < T : Into < String > > ( mut self , certificate : T ) -> Self {
270
287
self . export_config ( ) . certificate = Some ( certificate. into ( ) ) ;
271
288
self
272
289
}
273
290
291
+ #[ cfg( feature = "tls" ) ]
274
292
fn with_client_certificate < T : Into < String > > ( mut self , client_certificate : T ) -> Self {
275
293
self . export_config ( ) . client_certificate = Some ( client_certificate. into ( ) ) ;
276
294
self
277
295
}
278
296
297
+ #[ cfg( feature = "tls" ) ]
279
298
fn with_client_key < T : Into < String > > ( mut self , client_key : T ) -> Self {
280
299
self . export_config ( ) . client_key = Some ( client_key. into ( ) ) ;
281
300
self
0 commit comments