Skip to content

Commit 22f365f

Browse files
authored
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.
1 parent 45da275 commit 22f365f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

examples/basic-otlp/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use std::error::Error;
1414
use std::time::Duration;
1515

1616
fn init_tracer() -> Result<(sdktrace::Tracer, opentelemetry_otlp::Uninstall), TraceError> {
17-
opentelemetry_otlp::new_pipeline().install()
17+
opentelemetry_otlp::new_pipeline()
18+
.with_endpoint("http://localhost:4317")
19+
.install()
1820
}
1921

2022
// Skip first immediate tick from tokio, not needed for async_std.
@@ -97,7 +99,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
9799
});
98100
});
99101

100-
// wait for 1 seconds so that we could see metrics being pushed via OTLP every 10 seconds.
102+
// wait for 1 minutes so that we could see metrics being pushed via OTLP every 10 seconds.
101103
tokio::time::sleep(Duration::from_secs(60)).await;
102104

103105
Ok(())

opentelemetry-otlp/src/span.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Default for ExporterConfig {
140140
#[cfg(feature = "tonic")]
141141
fn default() -> Self {
142142
ExporterConfig {
143-
endpoint: format!("localhost:{}", DEFAULT_OTLP_PORT),
143+
endpoint: format!("http://localhost:{}", DEFAULT_OTLP_PORT),
144144
protocol: Protocol::Grpc,
145145
#[cfg(all(feature = "tonic", feature = "tls"))]
146146
tls_config: None,

0 commit comments

Comments
 (0)