From 22f365f0e58631ffc899f1993cf34aec9d068581 Mon Sep 17 00:00:00 2001 From: Zhongyang Wu Date: Sun, 24 Jan 2021 16:02:22 -0500 Subject: [PATCH] fix: basic_otlp example. (#438) Without http:// prefix, tonic will throw a panic. This commit fix it by use http://localhost as default endpoint. Also set it in example explicitly. --- examples/basic-otlp/src/main.rs | 6 ++++-- opentelemetry-otlp/src/span.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/basic-otlp/src/main.rs b/examples/basic-otlp/src/main.rs index a1f5226168..7e3398a345 100644 --- a/examples/basic-otlp/src/main.rs +++ b/examples/basic-otlp/src/main.rs @@ -14,7 +14,9 @@ use std::error::Error; use std::time::Duration; fn init_tracer() -> Result<(sdktrace::Tracer, opentelemetry_otlp::Uninstall), TraceError> { - opentelemetry_otlp::new_pipeline().install() + opentelemetry_otlp::new_pipeline() + .with_endpoint("http://localhost:4317") + .install() } // Skip first immediate tick from tokio, not needed for async_std. @@ -97,7 +99,7 @@ async fn main() -> Result<(), Box> { }); }); - // wait for 1 seconds so that we could see metrics being pushed via OTLP every 10 seconds. + // wait for 1 minutes so that we could see metrics being pushed via OTLP every 10 seconds. tokio::time::sleep(Duration::from_secs(60)).await; Ok(()) diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs index a755a8a7f0..f9acdd38f1 100644 --- a/opentelemetry-otlp/src/span.rs +++ b/opentelemetry-otlp/src/span.rs @@ -140,7 +140,7 @@ impl Default for ExporterConfig { #[cfg(feature = "tonic")] fn default() -> Self { ExporterConfig { - endpoint: format!("localhost:{}", DEFAULT_OTLP_PORT), + endpoint: format!("http://localhost:{}", DEFAULT_OTLP_PORT), protocol: Protocol::Grpc, #[cfg(all(feature = "tonic", feature = "tls"))] tls_config: None,