Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/in_opentelemetry/opentelemetry_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ static int send_response_ng(struct flb_http_response *response,
else if (http_status == 400) {
flb_http_response_set_message(response, "Bad Request");
}
else if (http_status == 404) {
flb_http_response_set_message(response, "Not Found");
}

if (message != NULL) {
flb_http_response_set_body(response,
Expand Down Expand Up @@ -828,7 +831,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request,
grpc_request = FLB_TRUE;
}
else {
send_response_ng(response, 400, "error: invalid endpoint\n");
send_response_ng(response, 404, "error: invalid endpoint\n");
return -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,27 @@ def test_in_opentelemetry_protocol_matrix(case, signal_type, json_input, endpoin
assert len(response_payload) > 0


def test_in_opentelemetry_http2_invalid_endpoint_returns_404():
service = Service(IN_OPENTELEMETRY_PROTOCOL_CONFIGS["http2_cleartext"])
service.start()

result = run_curl_request(
f"http://localhost:{service.flb_listener_port}/v1/invalid",
b"invalid payload",
headers=["Content-Type: application/x-protobuf"],
http_mode="http2-prior-knowledge",
)

service.stop()

assert result["status_code"] == 404
assert result["http_version"] == "2"
assert result["body"] == "error: invalid endpoint\n"
assert len(data_storage["logs"]) == 0
assert len(data_storage["metrics"]) == 0
assert len(data_storage["traces"]) == 0


# This test is branch-specific coverage for the generic HTTP listener worker mode.
# It does three things:
# 1. enables http_server.workers on the in_opentelemetry listener,
Expand Down
Loading