Skip to content

Commit

Permalink
Support "http" protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeschastny committed Jan 31, 2024
1 parent 28fd955 commit 430feaa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/otlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ fn infer_protocol_and_endpoint(
maybe_protocol: Option<&str>,
maybe_endpoint: Option<&str>,
) -> (String, String) {
let maybe_protocol = match maybe_protocol {
Some("grpc") => Some("grpc"),
Some("http") | Some("http/protobuf") => Some("http/protobuf"),
Some(other) => {
tracing::warn!(target: "otel::setup", "unsupported protocol {other:?}");
None
},
None => None,
};

let protocol = maybe_protocol.unwrap_or_else(|| {
if maybe_endpoint.map_or(false, |e| e.contains(":4317")) {
"grpc"
Expand All @@ -162,6 +172,7 @@ mod tests {
#[rstest]
#[case(None, None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138
#[case(Some("http/protobuf"), None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138
#[case(Some("http"), None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138
#[case(Some("grpc"), None, "grpc", "http://localhost:4317")] //Devskim: ignore DS137138
#[case(None, Some("http://localhost:4317"), "grpc", "http://localhost:4317")]
#[case(
Expand Down

0 comments on commit 430feaa

Please sign in to comment.