Skip to content

Commit 430feaa

Browse files
committed
Support "http" protocol
1 parent 28fd955 commit 430feaa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/otlp.rs

+11
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ fn infer_protocol_and_endpoint(
136136
maybe_protocol: Option<&str>,
137137
maybe_endpoint: Option<&str>,
138138
) -> (String, String) {
139+
let maybe_protocol = match maybe_protocol {
140+
Some("grpc") => Some("grpc"),
141+
Some("http") | Some("http/protobuf") => Some("http/protobuf"),
142+
Some(other) => {
143+
tracing::warn!(target: "otel::setup", "unsupported protocol {other:?}");
144+
None
145+
},
146+
None => None,
147+
};
148+
139149
let protocol = maybe_protocol.unwrap_or_else(|| {
140150
if maybe_endpoint.map_or(false, |e| e.contains(":4317")) {
141151
"grpc"
@@ -162,6 +172,7 @@ mod tests {
162172
#[rstest]
163173
#[case(None, None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138
164174
#[case(Some("http/protobuf"), None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138
175+
#[case(Some("http"), None, "http/protobuf", "http://localhost:4318")] //Devskim: ignore DS137138
165176
#[case(Some("grpc"), None, "grpc", "http://localhost:4317")] //Devskim: ignore DS137138
166177
#[case(None, Some("http://localhost:4317"), "grpc", "http://localhost:4317")]
167178
#[case(

0 commit comments

Comments
 (0)