From 049963fd3dddb3de838446fbbf23a14ead2c7a7d Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Fri, 3 Jun 2022 09:12:18 -0400
Subject: [PATCH 01/11] automatically add traces / metrics paths

---
 opentelemetry-otlp/src/exporter/mod.rs | 67 ++++++++------------------
 opentelemetry-otlp/src/lib.rs          | 16 +++---
 opentelemetry-otlp/src/metric.rs       | 25 ++++++++--
 opentelemetry-otlp/src/span.rs         | 23 ++++++++-
 4 files changed, 73 insertions(+), 58 deletions(-)

diff --git a/opentelemetry-otlp/src/exporter/mod.rs b/opentelemetry-otlp/src/exporter/mod.rs
index 1bb85c7ddc..fc2b398b52 100644
--- a/opentelemetry-otlp/src/exporter/mod.rs
+++ b/opentelemetry-otlp/src/exporter/mod.rs
@@ -12,20 +12,15 @@ use crate::Protocol;
 use std::str::FromStr;
 use std::time::Duration;
 
-/// Target to which the exporter is going to send spans or metrics, defaults to https://localhost:4317.
+/// Target to which the exporter is going to send signals, defaults to https://localhost:4317.
 pub const OTEL_EXPORTER_OTLP_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_ENDPOINT";
-/// Default target to which the exporter is going to send spans or metrics.
+/// Default target to which the exporter is going to send signals.
 pub const OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT: &str = "https://localhost:4317";
-/// Max waiting time for the backend to process each spans or metrics batch, defaults to 10 seconds.
+/// Max waiting time for the backend to process each signal batch, defaults to 10 seconds.
 pub const OTEL_EXPORTER_OTLP_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_TIMEOUT";
-/// Default max waiting time for the backend to process each spans or metrics batch.
+/// Default max waiting time for the backend to process each signal batch.
 pub const OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT: u64 = 10;
 
-/// Target to which the exporter is going to send spans, defaults to https://localhost:4317.
-pub const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
-/// Max waiting time for the backend to process each spans batch, defaults to 10s.
-pub const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT";
-
 #[cfg(feature = "grpc-sys")]
 pub(crate) mod grpcio;
 #[cfg(feature = "http-proto")]
@@ -36,7 +31,7 @@ pub(crate) mod tonic;
 /// Configuration for the OTLP exporter.
 #[derive(Debug)]
 pub struct ExportConfig {
-    /// The address of the OTLP collector. If not set, the default address is used.
+    /// The base address of the OTLP collector. If not set, the default address is used.
     pub endpoint: String,
 
     /// The protocol to use when communicating with the collector.
@@ -129,18 +124,15 @@ impl<B: HasExportConfig> WithExportConfig for B {
     }
 
     fn with_env(mut self) -> Self {
-        let endpoint = match std::env::var(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT) {
+        let endpoint = match std::env::var(OTEL_EXPORTER_OTLP_ENDPOINT) {
             Ok(val) => val,
-            Err(_) => std::env::var(OTEL_EXPORTER_OTLP_ENDPOINT)
-                .unwrap_or_else(|_| OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT.to_string()),
+            Err(_) => OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT.to_string()
         };
         self.export_config().endpoint = endpoint;
 
-        let timeout = match std::env::var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) {
+        let timeout = match std::env::var(OTEL_EXPORTER_OTLP_TIMEOUT) {
             Ok(val) => u64::from_str(&val).unwrap_or(OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT),
-            Err(_) => std::env::var(OTEL_EXPORTER_OTLP_TIMEOUT)
-                .map(|val| u64::from_str(&val).unwrap_or(OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT))
-                .unwrap_or(OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT),
+            Err(_) => OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
         };
         self.export_config().timeout = Duration::from_secs(timeout);
         self
@@ -159,17 +151,23 @@ impl<B: HasExportConfig> WithExportConfig for B {
 mod tests {
     use crate::exporter::{
         WithExportConfig, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TIMEOUT,
-        OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
-        OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
+        OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT
     };
     use crate::new_exporter;
 
     #[test]
-    fn test_pipeline_builder_from_env() {
-        std::env::set_var(OTEL_EXPORTER_OTLP_ENDPOINT, "https://otlp_endpoint:4317");
+    fn test_pipeline_builder_from_env_default_vars() {
+        let expected_endpoint = "https://otlp_endpoint:4317";
+        std::env::set_var(OTEL_EXPORTER_OTLP_ENDPOINT, expected_endpoint);
         std::env::set_var(OTEL_EXPORTER_OTLP_TIMEOUT, "bad_timeout");
 
         let mut exporter_builder = new_exporter().tonic().with_env();
+        assert_eq!(
+            exporter_builder.exporter_config.endpoint,
+            expected_endpoint
+        );
+
+        exporter_builder = new_exporter().tonic().with_env();
         assert_eq!(
             exporter_builder.exporter_config.timeout,
             std::time::Duration::from_secs(OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT)
@@ -187,31 +185,6 @@ mod tests {
         std::env::remove_var(OTEL_EXPORTER_OTLP_TIMEOUT);
         assert!(std::env::var(OTEL_EXPORTER_OTLP_ENDPOINT).is_err());
         assert!(std::env::var(OTEL_EXPORTER_OTLP_TIMEOUT).is_err());
+    }    
 
-        // test from traces env var
-        std::env::set_var(
-            OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
-            "https://otlp_traces_endpoint:4317",
-        );
-        std::env::set_var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT, "bad_timeout");
-
-        let mut exporter_builder = new_exporter().tonic().with_env();
-        assert_eq!(
-            exporter_builder.exporter_config.timeout,
-            std::time::Duration::from_secs(OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT)
-        );
-
-        std::env::set_var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT, "60");
-
-        exporter_builder = new_exporter().tonic().with_env();
-        assert_eq!(
-            exporter_builder.exporter_config.timeout,
-            std::time::Duration::from_secs(60)
-        );
-
-        std::env::remove_var(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT);
-        std::env::remove_var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT);
-        assert!(std::env::var(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT).is_err());
-        assert!(std::env::var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT).is_err());
-    }
 }
diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs
index adf6f70aae..d106adde07 100644
--- a/opentelemetry-otlp/src/lib.rs
+++ b/opentelemetry-otlp/src/lib.rs
@@ -189,16 +189,20 @@ mod transform;
 
 pub use crate::exporter::ExportConfig;
 #[cfg(feature = "trace")]
-pub use crate::span::{OtlpTracePipeline, SpanExporter, SpanExporterBuilder};
+pub use crate::span::{
+    OtlpTracePipeline, SpanExporter, SpanExporterBuilder, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
+    OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
+};
 
 #[cfg(feature = "metrics")]
-pub use crate::metric::{MetricsExporter, OtlpMetricPipeline};
+pub use crate::metric::{
+    MetricsExporter, OtlpMetricPipeline, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT,
+    OTEL_EXPORTER_OTLP_METRICS_TIMEOUT,
+};
 
 pub use crate::exporter::{
-    HasExportConfig, WithExportConfig, OTEL_EXPORTER_OTLP_ENDPOINT,
-    OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT, OTEL_EXPORTER_OTLP_TIMEOUT,
-    OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
-    OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
+    HasExportConfig, WithExportConfig, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TIMEOUT,
+    OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT, OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT
 };
 
 use opentelemetry::sdk::export::ExportError;
diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index 95bd07667b..068babcf1c 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -25,15 +25,22 @@ use opentelemetry_proto::tonic::collector::metrics::v1::{
     metrics_service_client::MetricsServiceClient, ExportMetricsServiceRequest,
 };
 use std::fmt::{Debug, Formatter};
+use std::str::FromStr;
 use std::sync::Arc;
 use std::sync::Mutex;
 use std::time;
+use std::time::Duration;
 use tonic::metadata::KeyAndValueRef;
 #[cfg(feature = "grpc-tonic")]
 use tonic::transport::Channel;
 #[cfg(feature = "grpc-tonic")]
 use tonic::Request;
 
+/// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
+pub const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
+/// Max waiting time for the backend to process each metrics batch, defaults to 10s.
+pub const OTEL_EXPORTER_OTLP_METRICS_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT";
+
 impl OtlpPipeline {
     /// Create a OTLP metrics pipeline.
     pub fn metrics<SP, SO, I, IO>(
@@ -263,8 +270,20 @@ impl MetricsExporter {
         mut tonic_config: TonicConfig,
         export_selector: T,
     ) -> Result<MetricsExporter> {
-        let endpoint =
-            Channel::from_shared(config.endpoint).map_err::<crate::Error, _>(Into::into)?;
+        let endpoint = match std::env::var(OTEL_EXPORTER_OTLP_METRICS_ENDPOINT) {
+            Ok(val) => val,
+            Err(_) => format!("{}{}", config.endpoint, "/v1/metrics"),
+        };
+
+        let timeout = match std::env::var(OTEL_EXPORTER_OTLP_METRICS_TIMEOUT) {
+            Ok(val) => match u64::from_str(&val) {
+                Ok(seconds) => Duration::from_secs(seconds),
+                Err(_) => config.timeout,
+            },
+            Err(_) => config.timeout,
+        };
+
+        let endpoint = Channel::from_shared(endpoint).map_err::<crate::Error, _>(Into::into)?;
 
         #[cfg(all(feature = "tls"))]
         let channel = match tonic_config.tls_config {
@@ -273,7 +292,7 @@ impl MetricsExporter {
                 .map_err::<crate::Error, _>(Into::into)?,
             None => endpoint,
         }
-        .timeout(config.timeout)
+        .timeout(timeout)
         .connect_lazy();
 
         #[cfg(not(feature = "tls"))]
diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index bd10626e35..6ad8456a87 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -3,6 +3,7 @@
 //! Defines a [SpanExporter] to send trace data via the OpenTelemetry Protocol (OTLP)
 
 use std::fmt::{self, Debug};
+use std::str::FromStr;
 use std::time::Duration;
 
 #[cfg(feature = "grpc-tonic")]
@@ -63,6 +64,11 @@ use opentelemetry::{
 
 use async_trait::async_trait;
 
+/// Target to which the exporter is going to send spans, defaults to https://localhost:4317.
+pub const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
+/// Max waiting time for the backend to process each spans batch, defaults to 10s.
+pub const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT";
+
 impl OtlpPipeline {
     /// Create a OTLP tracing pipeline.
     pub fn tracing(self) -> OtlpTracePipeline {
@@ -313,14 +319,27 @@ impl SpanExporter {
         config: ExportConfig,
         tonic_config: TonicConfig,
     ) -> Result<Self, crate::Error> {
-        let endpoint = TonicChannel::from_shared(config.endpoint.clone())?;
+        let endpoint_str = match std::env::var(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT) {
+            Ok(val) => val,
+            Err(_) => format!("{}{}", config.endpoint, "/v1/traces"),
+        };
+
+        let endpoint = TonicChannel::from_shared(endpoint_str)?;
+
+        let timeout = match std::env::var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) {
+            Ok(val) => match u64::from_str(&val) {
+                Ok(seconds) => Duration::from_secs(seconds),
+                Err(_) => config.timeout,
+            },
+            Err(_) => config.timeout,
+        };
 
         #[cfg(feature = "tls")]
         let channel = match tonic_config.tls_config.as_ref() {
             Some(tls_config) => endpoint.tls_config(tls_config.clone())?,
             None => endpoint,
         }
-        .timeout(config.timeout)
+        .timeout(timeout)
         .connect_lazy();
 
         #[cfg(not(feature = "tls"))]

From 0e72b4b4c7a83af93f8cec3368b93b60fc0711e2 Mon Sep 17 00:00:00 2001
From: Gary White Jr <7660110+GaryPWhite@users.noreply.github.com>
Date: Mon, 13 Jun 2022 09:19:09 -0400
Subject: [PATCH 02/11] Update opentelemetry-otlp/src/span.rs

Co-authored-by: Zhongyang Wu <zhongyang.wu@outlook.com>
---
 opentelemetry-otlp/src/span.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index 6ad8456a87..efdc20be2d 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -64,7 +64,7 @@ use opentelemetry::{
 
 use async_trait::async_trait;
 
-/// Target to which the exporter is going to send spans, defaults to https://localhost:4317.
+/// Target to which the exporter is going to send spans, defaults to https://localhost:4317/v1/traces.
 pub const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
 /// Max waiting time for the backend to process each spans batch, defaults to 10s.
 pub const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT";

From 0e43740e4b269adf53df7960d7f2c22fd82c3de9 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 13 Jun 2022 09:25:06 -0400
Subject: [PATCH 03/11] fmt

---
 opentelemetry-otlp/src/exporter/mod.rs | 12 ++++--------
 opentelemetry-otlp/src/lib.rs          |  5 +++--
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/opentelemetry-otlp/src/exporter/mod.rs b/opentelemetry-otlp/src/exporter/mod.rs
index fc2b398b52..9e05459c37 100644
--- a/opentelemetry-otlp/src/exporter/mod.rs
+++ b/opentelemetry-otlp/src/exporter/mod.rs
@@ -126,7 +126,7 @@ impl<B: HasExportConfig> WithExportConfig for B {
     fn with_env(mut self) -> Self {
         let endpoint = match std::env::var(OTEL_EXPORTER_OTLP_ENDPOINT) {
             Ok(val) => val,
-            Err(_) => OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT.to_string()
+            Err(_) => OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT.to_string(),
         };
         self.export_config().endpoint = endpoint;
 
@@ -151,7 +151,7 @@ impl<B: HasExportConfig> WithExportConfig for B {
 mod tests {
     use crate::exporter::{
         WithExportConfig, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TIMEOUT,
-        OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT
+        OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
     };
     use crate::new_exporter;
 
@@ -162,10 +162,7 @@ mod tests {
         std::env::set_var(OTEL_EXPORTER_OTLP_TIMEOUT, "bad_timeout");
 
         let mut exporter_builder = new_exporter().tonic().with_env();
-        assert_eq!(
-            exporter_builder.exporter_config.endpoint,
-            expected_endpoint
-        );
+        assert_eq!(exporter_builder.exporter_config.endpoint, expected_endpoint);
 
         exporter_builder = new_exporter().tonic().with_env();
         assert_eq!(
@@ -185,6 +182,5 @@ mod tests {
         std::env::remove_var(OTEL_EXPORTER_OTLP_TIMEOUT);
         assert!(std::env::var(OTEL_EXPORTER_OTLP_ENDPOINT).is_err());
         assert!(std::env::var(OTEL_EXPORTER_OTLP_TIMEOUT).is_err());
-    }    
-
+    }
 }
diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs
index d106adde07..8588de6ffd 100644
--- a/opentelemetry-otlp/src/lib.rs
+++ b/opentelemetry-otlp/src/lib.rs
@@ -201,8 +201,9 @@ pub use crate::metric::{
 };
 
 pub use crate::exporter::{
-    HasExportConfig, WithExportConfig, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TIMEOUT,
-    OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT, OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT
+    HasExportConfig, WithExportConfig, OTEL_EXPORTER_OTLP_ENDPOINT,
+    OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT, OTEL_EXPORTER_OTLP_TIMEOUT,
+    OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
 };
 
 use opentelemetry::sdk::export::ExportError;

From 395ea3870636747ae5657139bff8f7b388d07625 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 13 Jun 2022 09:28:49 -0400
Subject: [PATCH 04/11] merge from upstream

---
 opentelemetry-otlp/src/exporter/mod.rs | 2 ++
 opentelemetry-otlp/src/metric.rs       | 2 ++
 opentelemetry-otlp/src/span.rs         | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/opentelemetry-otlp/src/exporter/mod.rs b/opentelemetry-otlp/src/exporter/mod.rs
index 9e05459c37..834ce828bf 100644
--- a/opentelemetry-otlp/src/exporter/mod.rs
+++ b/opentelemetry-otlp/src/exporter/mod.rs
@@ -13,6 +13,8 @@ use std::str::FromStr;
 use std::time::Duration;
 
 /// Target to which the exporter is going to send signals, defaults to https://localhost:4317.
+/// Learn about the relationship between this constant and metrics/spans/logs at 
+/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
 pub const OTEL_EXPORTER_OTLP_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_ENDPOINT";
 /// Default target to which the exporter is going to send signals.
 pub const OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT: &str = "https://localhost:4317";
diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index 068babcf1c..a77a6aaf12 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -37,6 +37,8 @@ use tonic::transport::Channel;
 use tonic::Request;
 
 /// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
+/// Learn about the relationship between this constant and default/spans/logs at 
+/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
 pub const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
 /// Max waiting time for the backend to process each metrics batch, defaults to 10s.
 pub const OTEL_EXPORTER_OTLP_METRICS_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT";
diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index efdc20be2d..1a79b0425e 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -65,6 +65,8 @@ use opentelemetry::{
 use async_trait::async_trait;
 
 /// Target to which the exporter is going to send spans, defaults to https://localhost:4317/v1/traces.
+/// Learn about the relationship between this constant and default/metrics/logs at 
+/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
 pub const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
 /// Max waiting time for the backend to process each spans batch, defaults to 10s.
 pub const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT";

From 264e58b4aee8d26af649b178daa073d427a80efe Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 13 Jun 2022 09:41:55 -0400
Subject: [PATCH 05/11] more formatting -- oops

---
 opentelemetry-otlp/src/exporter/mod.rs | 2 +-
 opentelemetry-otlp/src/metric.rs       | 2 +-
 opentelemetry-otlp/src/span.rs         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opentelemetry-otlp/src/exporter/mod.rs b/opentelemetry-otlp/src/exporter/mod.rs
index 834ce828bf..cfe84a58a8 100644
--- a/opentelemetry-otlp/src/exporter/mod.rs
+++ b/opentelemetry-otlp/src/exporter/mod.rs
@@ -13,7 +13,7 @@ use std::str::FromStr;
 use std::time::Duration;
 
 /// Target to which the exporter is going to send signals, defaults to https://localhost:4317.
-/// Learn about the relationship between this constant and metrics/spans/logs at 
+/// Learn about the relationship between this constant and metrics/spans/logs at
 /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
 pub const OTEL_EXPORTER_OTLP_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_ENDPOINT";
 /// Default target to which the exporter is going to send signals.
diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index a77a6aaf12..7564811031 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -37,7 +37,7 @@ use tonic::transport::Channel;
 use tonic::Request;
 
 /// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
-/// Learn about the relationship between this constant and default/spans/logs at 
+/// Learn about the relationship between this constant and default/spans/logs at
 /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
 pub const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
 /// Max waiting time for the backend to process each metrics batch, defaults to 10s.
diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index 1a79b0425e..286d03f467 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -65,7 +65,7 @@ use opentelemetry::{
 use async_trait::async_trait;
 
 /// Target to which the exporter is going to send spans, defaults to https://localhost:4317/v1/traces.
-/// Learn about the relationship between this constant and default/metrics/logs at 
+/// Learn about the relationship between this constant and default/metrics/logs at
 /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
 pub const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
 /// Max waiting time for the backend to process each spans batch, defaults to 10s.

From 1a171ea6f3ebc54a521f74cdc596f9ba9937bb65 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Thu, 16 Jun 2022 10:31:51 -0400
Subject: [PATCH 06/11] sometimes compilation doesn't use timeout

---
 opentelemetry-otlp/src/span.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index 286d03f467..0b3f7a38b1 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -328,7 +328,7 @@ impl SpanExporter {
 
         let endpoint = TonicChannel::from_shared(endpoint_str)?;
 
-        let timeout = match std::env::var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) {
+        let _timeout = match std::env::var(OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) {
             Ok(val) => match u64::from_str(&val) {
                 Ok(seconds) => Duration::from_secs(seconds),
                 Err(_) => config.timeout,
@@ -341,11 +341,11 @@ impl SpanExporter {
             Some(tls_config) => endpoint.tls_config(tls_config.clone())?,
             None => endpoint,
         }
-        .timeout(timeout)
+        .timeout(_timeout)
         .connect_lazy();
 
         #[cfg(not(feature = "tls"))]
-        let channel = endpoint.timeout(config.timeout).connect_lazy();
+        let channel = endpoint.timeout(_timeout).connect_lazy();
 
         SpanExporter::from_tonic_channel(config, tonic_config, channel)
     }

From 011d31fdd6a0df62936925b53cb592e4c423df7c Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 20 Jun 2022 11:43:18 -0400
Subject: [PATCH 07/11] remove fromstr

---
 opentelemetry-otlp/src/metric.rs | 1 -
 opentelemetry-otlp/src/span.rs   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index 7564811031..7443544f99 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -25,7 +25,6 @@ use opentelemetry_proto::tonic::collector::metrics::v1::{
     metrics_service_client::MetricsServiceClient, ExportMetricsServiceRequest,
 };
 use std::fmt::{Debug, Formatter};
-use std::str::FromStr;
 use std::sync::Arc;
 use std::sync::Mutex;
 use std::time;
diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index 0b3f7a38b1..af63f6f0c1 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -3,7 +3,6 @@
 //! Defines a [SpanExporter] to send trace data via the OpenTelemetry Protocol (OTLP)
 
 use std::fmt::{self, Debug};
-use std::str::FromStr;
 use std::time::Duration;
 
 #[cfg(feature = "grpc-tonic")]

From 195b3e1bebbb9ef360edbb666e94b1eb8b888be6 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 20 Jun 2022 13:17:22 -0400
Subject: [PATCH 08/11] ah, import only when using 'grpc-tonic'

---
 opentelemetry-otlp/src/metric.rs | 2 ++
 opentelemetry-otlp/src/span.rs   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index 7443544f99..6e05cdf49e 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -34,6 +34,8 @@ use tonic::metadata::KeyAndValueRef;
 use tonic::transport::Channel;
 #[cfg(feature = "grpc-tonic")]
 use tonic::Request;
+#[cfg(feature = "grpc-tonic")]
+use std::str::FromStr;
 
 /// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
 /// Learn about the relationship between this constant and default/spans/logs at
diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index af63f6f0c1..638a92da67 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -5,6 +5,8 @@
 use std::fmt::{self, Debug};
 use std::time::Duration;
 
+#[cfg(feature = "grpc-tonic")]
+use std::str::FromStr;
 #[cfg(feature = "grpc-tonic")]
 use {
     crate::exporter::tonic::{TonicConfig, TonicExporterBuilder},

From 78f5c945d7f53ddf6b3fa8c044a317156aa82487 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 20 Jun 2022 14:52:24 -0400
Subject: [PATCH 09/11] formatting for rustdoc links

---
 opentelemetry-otlp/src/exporter/mod.rs | 2 +-
 opentelemetry-otlp/src/metric.rs       | 2 +-
 opentelemetry-otlp/src/span.rs         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opentelemetry-otlp/src/exporter/mod.rs b/opentelemetry-otlp/src/exporter/mod.rs
index cfe84a58a8..6f54f3166e 100644
--- a/opentelemetry-otlp/src/exporter/mod.rs
+++ b/opentelemetry-otlp/src/exporter/mod.rs
@@ -14,7 +14,7 @@ use std::time::Duration;
 
 /// Target to which the exporter is going to send signals, defaults to https://localhost:4317.
 /// Learn about the relationship between this constant and metrics/spans/logs at
-/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
+/// <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp>
 pub const OTEL_EXPORTER_OTLP_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_ENDPOINT";
 /// Default target to which the exporter is going to send signals.
 pub const OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT: &str = "https://localhost:4317";
diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index 6e05cdf49e..ab0d399492 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -39,7 +39,7 @@ use std::str::FromStr;
 
 /// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
 /// Learn about the relationship between this constant and default/spans/logs at
-/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
+/// <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp>
 pub const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
 /// Max waiting time for the backend to process each metrics batch, defaults to 10s.
 pub const OTEL_EXPORTER_OTLP_METRICS_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT";
diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs
index 638a92da67..fb8acb2f33 100644
--- a/opentelemetry-otlp/src/span.rs
+++ b/opentelemetry-otlp/src/span.rs
@@ -67,7 +67,7 @@ use async_trait::async_trait;
 
 /// Target to which the exporter is going to send spans, defaults to https://localhost:4317/v1/traces.
 /// Learn about the relationship between this constant and default/metrics/logs at
-/// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
+/// <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp>
 pub const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: &str = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
 /// Max waiting time for the backend to process each spans batch, defaults to 10s.
 pub const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: &str = "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT";

From 04e6a726a8e95856962fd1aab9046742a015c2c0 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 20 Jun 2022 14:53:00 -0400
Subject: [PATCH 10/11] fmt

---
 opentelemetry-otlp/src/metric.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index ab0d399492..cbc05e1571 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -25,6 +25,8 @@ use opentelemetry_proto::tonic::collector::metrics::v1::{
     metrics_service_client::MetricsServiceClient, ExportMetricsServiceRequest,
 };
 use std::fmt::{Debug, Formatter};
+#[cfg(feature = "grpc-tonic")]
+use std::str::FromStr;
 use std::sync::Arc;
 use std::sync::Mutex;
 use std::time;
@@ -34,8 +36,6 @@ use tonic::metadata::KeyAndValueRef;
 use tonic::transport::Channel;
 #[cfg(feature = "grpc-tonic")]
 use tonic::Request;
-#[cfg(feature = "grpc-tonic")]
-use std::str::FromStr;
 
 /// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
 /// Learn about the relationship between this constant and default/spans/logs at

From ed5eae50d6bf689d389af52a36938577135fbac6 Mon Sep 17 00:00:00 2001
From: Gary White Jr <gwhite@wayfair.com>
Date: Mon, 20 Jun 2022 16:22:43 -0400
Subject: [PATCH 11/11] _timeout instead of timeout

---
 opentelemetry-otlp/src/metric.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs
index cbc05e1571..a3efd7065b 100644
--- a/opentelemetry-otlp/src/metric.rs
+++ b/opentelemetry-otlp/src/metric.rs
@@ -278,7 +278,7 @@ impl MetricsExporter {
             Err(_) => format!("{}{}", config.endpoint, "/v1/metrics"),
         };
 
-        let timeout = match std::env::var(OTEL_EXPORTER_OTLP_METRICS_TIMEOUT) {
+        let _timeout = match std::env::var(OTEL_EXPORTER_OTLP_METRICS_TIMEOUT) {
             Ok(val) => match u64::from_str(&val) {
                 Ok(seconds) => Duration::from_secs(seconds),
                 Err(_) => config.timeout,
@@ -295,7 +295,7 @@ impl MetricsExporter {
                 .map_err::<crate::Error, _>(Into::into)?,
             None => endpoint,
         }
-        .timeout(timeout)
+        .timeout(_timeout)
         .connect_lazy();
 
         #[cfg(not(feature = "tls"))]