Skip to content

Commit ae15a91

Browse files
committed
add more docs
1 parent 8a745ca commit ae15a91

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

opentelemetry-otlp/CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
new one returns specific variants applicable to building an exporter. Some
1919
variants might be applicable only on select features.
2020
- **Breaking** `ExportConfig`'s `timeout` field is now optional(`Option<Duration>`)
21-
- **Breaking** Configuration done via code is final. ENV variables cannot be used to override the code config. Do not use code based config, if there is desire to control the settings via ENV variables.
22-
List of ENV variables and corresponding setting being affected by this change.
23-
priority changed in favor of compile time values. Additionally the `endpoint`
24-
field prioritizes compile time values over environment variables.
21+
- **Breaking** Export configuration done via code is final. ENV variables cannot be used to override the code config.
22+
Do not use code based config, if there is desire to control the settings via ENV variables.
23+
List of ENV variables and corresponding setting being affected by this change.
24+
- `OTEL_EXPORTER_OTLP_ENDPOINT` -> `ExportConfig.endpoint`
25+
- `OTEL_EXPORTER_OTLP_TIMEOUT` -> `ExportConfig.timeout`
2526

2627
## 0.28.0
2728

opentelemetry-otlp/src/exporter/mod.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::exporter::tonic::TonicExporterBuilder;
99
use crate::Protocol;
1010
#[cfg(feature = "serialize")]
1111
use serde::{Deserialize, Serialize};
12-
use std::env;
1312
use std::fmt::{Display, Formatter};
1413
use std::str::FromStr;
1514
use std::time::Duration;
@@ -69,14 +68,19 @@ pub(crate) mod tonic;
6968
/// Configuration for the OTLP exporter.
7069
#[derive(Debug)]
7170
pub struct ExportConfig {
72-
/// The address of the OTLP collector. If it's not provided via builder or environment variables.
71+
/// The address of the OTLP collector.
7372
/// Default address will be used based on the protocol.
73+
///
74+
/// Note: Programmatically setting this will override any value set via the environment variable.
7475
pub endpoint: Option<String>,
7576

7677
/// The protocol to use when communicating with the collector.
7778
pub protocol: Protocol,
7879

7980
/// The timeout to the collector.
81+
/// The default value is 10 seconds.
82+
///
83+
/// Note: Programmatically setting this will override any value set via the environment variable.
8084
pub timeout: Option<Duration>,
8185
}
8286

@@ -224,18 +228,24 @@ impl HasExportConfig for HttpExporterBuilder {
224228
/// ```
225229
pub trait WithExportConfig {
226230
/// Set the address of the OTLP collector. If not set or set to empty string, the default address is used.
231+
///
232+
/// Note: Programmatically setting this will override any value set via the environment variable.
227233
fn with_endpoint<T: Into<String>>(self, endpoint: T) -> Self;
228234
/// Set the protocol to use when communicating with the collector.
229235
///
230236
/// Note that protocols that are not supported by exporters will be ignored. The exporter
231237
/// will use default protocol in this case.
232238
///
233239
/// ## Note
234-
/// All exporters in this crate only support one protocol, thus choosing the protocol is an no-op at the moment.
240+
/// All exporters in this crate only support one protocol, thus choosing the protocol is a no-op at the moment.
235241
fn with_protocol(self, protocol: Protocol) -> Self;
236242
/// Set the timeout to the collector.
243+
///
244+
/// Note: Programmatically setting this will override any value set via the environment variable.
237245
fn with_timeout(self, timeout: Duration) -> Self;
238-
/// Set export config. This will override all previous configuration.
246+
/// Set export config. This will override all previous configurations.
247+
///
248+
/// Note: Programmatically setting this will override any value set via environment variables.
239249
fn with_export_config(self, export_config: ExportConfig) -> Self;
240250
}
241251

@@ -263,17 +273,18 @@ impl<B: HasExportConfig> WithExportConfig for B {
263273
}
264274
}
265275

276+
#[cfg(any(feature = "grpc-tonic", feature = "http-proto", feature = "http-json"))]
266277
fn resolve_timeout(signal_timeout_var: &str, provided_timeout: Option<&Duration>) -> Duration {
267278
// programmatic configuration overrides any value set via environment variables
268279
if let Some(timeout) = provided_timeout {
269280
*timeout
270-
} else if let Some(timeout) = env::var(signal_timeout_var)
281+
} else if let Some(timeout) = std::env::var(signal_timeout_var)
271282
.ok()
272283
.and_then(|s| s.parse().ok())
273284
{
274285
// per signal env var is not modified
275286
Duration::from_millis(timeout)
276-
} else if let Some(timeout) = env::var(OTEL_EXPORTER_OTLP_TIMEOUT)
287+
} else if let Some(timeout) = std::env::var(OTEL_EXPORTER_OTLP_TIMEOUT)
277288
.ok()
278289
.and_then(|s| s.parse().ok())
279290
{

0 commit comments

Comments
 (0)