Skip to content

Commit

Permalink
opentelemetry-otlp: Default the port correctly.
Browse files Browse the repository at this point in the history
Current behavior uses http-proto port even when there's no desire to use
it.

Relates #1509

Signed-off-by: Harold Dost <h.dost@criteo.com>
  • Loading branch information
hdost committed Feb 18, 2024
1 parent 1be83bb commit 4b478c8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
8 changes: 7 additions & 1 deletion opentelemetry-otlp/CHANGELOG.md
Expand Up @@ -2,8 +2,14 @@

## vNext

- **Breaking** Remove support for surf HTTP client [#1537](https://github.com/open-telemetry/opentelemetry-rust/pull/1537)
### Fixed
- Fix `tonic()` to the use correct port. [#1556](https://github.com/open-telemetry/opentelemetry-rust/pull/1556)

### Changed
- Update to tonic 0.11 and prost 0.12 (#1536)

### Removed
- **Breaking** Remove support for surf HTTP client [#1537](https://github.com/open-telemetry/opentelemetry-rust/pull/1537)
- Remove support for grpcio transport (#1534)

## v0.14.0
Expand Down
22 changes: 22 additions & 0 deletions opentelemetry-otlp/src/exporter/mod.rs
Expand Up @@ -245,6 +245,28 @@ mod tests {
)
}

#[cfg(feature = "http-proto")]
#[test]
fn test_default_http_endpoint() {
let exporter_builder = crate::new_exporter().http();

assert_eq!(
exporter_builder.exporter_config.endpoint,
"http://localhost:4318"
);
}

#[cfg(feature = "grpc-tonic")]
#[test]
fn test_default_tonic_endpoint() {
let exporter_builder = crate::new_exporter().tonic();

assert_eq!(
exporter_builder.exporter_config.endpoint,
"http://localhost:4317"
);
}

#[test]
fn test_parse_header_string() {
let test_cases = vec![
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-otlp/src/exporter/tonic/mod.rs
Expand Up @@ -149,6 +149,7 @@ impl Default for TonicExporterBuilder {
TonicExporterBuilder {
exporter_config: ExportConfig {
protocol: crate::Protocol::Grpc,
endpoint: crate::exporter::default_endpoint(crate::Protocol::Grpc),
..Default::default()
},
tonic_config,
Expand Down
7 changes: 1 addition & 6 deletions opentelemetry-otlp/tests/integration_test/tests/traces.rs
Expand Up @@ -6,7 +6,6 @@ use opentelemetry::{
trace::{TraceContextExt, Tracer},
Key, KeyValue,
};
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{runtime, trace as sdktrace, Resource};
use std::error::Error;
use std::fs::File;
Expand All @@ -15,11 +14,7 @@ use std::os::unix::fs::MetadataExt;
fn init_tracer() -> Result<sdktrace::Tracer, TraceError> {
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://localhost:4317"),
)
.with_exporter(opentelemetry_otlp::new_exporter().tonic())
.with_trace_config(
sdktrace::config().with_resource(Resource::new(vec![KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
Expand Down

0 comments on commit 4b478c8

Please sign in to comment.