Skip to content

Commit

Permalink
fix: basic_otlp example. (open-telemetry#438)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TommyCpp authored Jan 24, 2021
1 parent 45da275 commit 22f365f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions examples/basic-otlp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -97,7 +99,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
});
});

// 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(())
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 22f365f

Please sign in to comment.