Skip to content

Commit b0ed39d

Browse files
committed
fix: add missing TLS configuration directives.
Add missing TLS configuration directives. Signed-off-by: José Guilherme Vanz <[email protected]>
1 parent 3023fc3 commit b0ed39d

File tree

1 file changed

+20
-1
lines changed
  • opentelemetry-otlp/src/exporter

1 file changed

+20
-1
lines changed

opentelemetry-otlp/src/exporter/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ pub struct ExportConfig {
9797
pub timeout: Option<Duration>,
9898

9999
/// Disable TLS
100+
#[cfg(feature = "tls")]
100101
pub insecure: Option<bool>,
101102

102103
/// The certificate file to validate the OTLP server connection
104+
#[cfg(feature = "tls")]
103105
pub certificate: Option<String>,
104106

105107
/// The path to the certificate file to use for client authentication (mTLS).
108+
#[cfg(feature = "tls")]
106109
pub client_certificate: Option<String>,
107110

108111
/// The path to the key file to use for client authentication (mTLS).
112+
#[cfg(feature = "tls")]
109113
pub client_key: Option<String>,
110114
}
111115

@@ -119,9 +123,13 @@ impl Default for ExportConfig {
119123
// won't know if user provided a value
120124
protocol,
121125
timeout: None,
126+
#[cfg(feature = "tls")]
122127
insecure: None,
128+
#[cfg(feature = "tls")]
123129
certificate: None,
130+
#[cfg(feature = "tls")]
124131
client_certificate: None,
132+
#[cfg(feature = "tls")]
125133
client_key: None,
126134
}
127135
}
@@ -277,15 +285,19 @@ pub trait WithExportConfig {
277285
/// Note: Programmatically setting this will override any value set via environment variables.
278286
fn with_export_config(self, export_config: ExportConfig) -> Self;
279287
/// Set insecure connection. Disable TLS
288+
#[cfg(feature = "tls")]
280289
fn with_insecure(self) -> Self;
281290
/// Set the certificate file to validate the OTLP server connection
282291
/// This is only available when the `tls` feature is enabled.
292+
#[cfg(feature = "tls")]
283293
fn with_certificate<T: Into<String>>(self, certificate: T) -> Self;
284294
/// Set the path to the certificate file to use for client authentication (mTLS).
285295
/// This is only available when the `tls` feature is enabled.
296+
#[cfg(feature = "tls")]
286297
fn with_client_certificate<T: Into<String>>(self, client_certificate: T) -> Self;
287298
/// Set the path to the key file to use for client authentication (mTLS).
288299
/// This is only available when the `tls` feature is enabled.
300+
#[cfg(feature = "tls")]
289301
fn with_client_key<T: Into<String>>(self, client_key: T) -> Self;
290302
}
291303

@@ -309,25 +321,32 @@ impl<B: HasExportConfig> WithExportConfig for B {
309321
self.export_config().endpoint = exporter_config.endpoint;
310322
self.export_config().protocol = exporter_config.protocol;
311323
self.export_config().timeout = exporter_config.timeout;
312-
self.export_config().insecure = Some(true);
324+
#[cfg(feature = "tls")]
325+
{
326+
self.export_config().insecure = Some(true);
327+
}
313328
self
314329
}
315330

331+
#[cfg(feature = "tls")]
316332
fn with_insecure(mut self) -> Self {
317333
self.export_config().insecure = Some(true);
318334
self
319335
}
320336

337+
#[cfg(feature = "tls")]
321338
fn with_certificate<T: Into<String>>(mut self, certificate: T) -> Self {
322339
self.export_config().certificate = Some(certificate.into());
323340
self
324341
}
325342

343+
#[cfg(feature = "tls")]
326344
fn with_client_certificate<T: Into<String>>(mut self, client_certificate: T) -> Self {
327345
self.export_config().client_certificate = Some(client_certificate.into());
328346
self
329347
}
330348

349+
#[cfg(feature = "tls")]
331350
fn with_client_key<T: Into<String>>(mut self, client_key: T) -> Self {
332351
self.export_config().client_key = Some(client_key.into());
333352
self

0 commit comments

Comments
 (0)