Skip to content

Commit 07e62dd

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

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

+20-1
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,19 @@ pub struct ExportConfig {
9191
pub timeout: Duration,
9292

9393
/// Disable TLS
94+
#[cfg(feature = "tls")]
9495
pub insecure: Option<bool>,
9596

9697
/// The certificate file to validate the OTLP server connection
98+
#[cfg(feature = "tls")]
9799
pub certificate: Option<String>,
98100

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

102105
/// The path to the key file to use for client authentication (mTLS).
106+
#[cfg(feature = "tls")]
103107
pub client_key: Option<String>,
104108
}
105109

@@ -113,9 +117,13 @@ impl Default for ExportConfig {
113117
// won't know if user provided a value
114118
protocol,
115119
timeout: Duration::from_secs(OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT),
120+
#[cfg(feature = "tls")]
116121
insecure: None,
122+
#[cfg(feature = "tls")]
117123
certificate: None,
124+
#[cfg(feature = "tls")]
118125
client_certificate: None,
126+
#[cfg(feature = "tls")]
119127
client_key: None,
120128
}
121129
}
@@ -225,15 +233,19 @@ pub trait WithExportConfig {
225233
/// Set export config. This will override all previous configuration.
226234
fn with_export_config(self, export_config: ExportConfig) -> Self;
227235
/// Set insecure connection. Disable TLS
236+
#[cfg(feature = "tls")]
228237
fn with_insecure(self) -> Self;
229238
/// Set the certificate file to validate the OTLP server connection
230239
/// This is only available when the `tls` feature is enabled.
240+
#[cfg(feature = "tls")]
231241
fn with_certificate<T: Into<String>>(self, certificate: T) -> Self;
232242
/// Set the path to the certificate file to use for client authentication (mTLS).
233243
/// This is only available when the `tls` feature is enabled.
244+
#[cfg(feature = "tls")]
234245
fn with_client_certificate<T: Into<String>>(self, client_certificate: T) -> Self;
235246
/// Set the path to the key file to use for client authentication (mTLS).
236247
/// This is only available when the `tls` feature is enabled.
248+
#[cfg(feature = "tls")]
237249
fn with_client_key<T: Into<String>>(self, client_key: T) -> Self;
238250
}
239251

@@ -257,25 +269,32 @@ impl<B: HasExportConfig> WithExportConfig for B {
257269
self.export_config().endpoint = exporter_config.endpoint;
258270
self.export_config().protocol = exporter_config.protocol;
259271
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+
}
261276
self
262277
}
263278

279+
#[cfg(feature = "tls")]
264280
fn with_insecure(mut self) -> Self {
265281
self.export_config().insecure = Some(true);
266282
self
267283
}
268284

285+
#[cfg(feature = "tls")]
269286
fn with_certificate<T: Into<String>>(mut self, certificate: T) -> Self {
270287
self.export_config().certificate = Some(certificate.into());
271288
self
272289
}
273290

291+
#[cfg(feature = "tls")]
274292
fn with_client_certificate<T: Into<String>>(mut self, client_certificate: T) -> Self {
275293
self.export_config().client_certificate = Some(client_certificate.into());
276294
self
277295
}
278296

297+
#[cfg(feature = "tls")]
279298
fn with_client_key<T: Into<String>>(mut self, client_key: T) -> Self {
280299
self.export_config().client_key = Some(client_key.into());
281300
self

0 commit comments

Comments
 (0)