Skip to content

Commit

Permalink
Support PROTO_TEXT format in UDP sink for tap
Browse files Browse the repository at this point in the history
Signed-off-by: fchen7 <cliff.chen@nokia-sbell.com>
  • Loading branch information
coolg92003 committed Feb 19, 2025
1 parent cedb633 commit 88e8ccc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions contrib/tap_sinks/udp_sink/source/udp_sink_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ void UdpTapSink::UdpTapSinkHandle::submitTrace(TapCommon::TraceWrapperPtr&& trac
case envoy::config::tap::v3::OutputSink::PROTO_BINARY:
FALLTHRU;
case envoy::config::tap::v3::OutputSink::PROTO_BINARY_LENGTH_DELIMITED:
FALLTHRU;
case envoy::config::tap::v3::OutputSink::PROTO_TEXT:
// will implement above format if it is needed.
ENVOY_LOG_MISC(debug,
"{}: Not support PROTO_BINARY, PROTO_BINARY_LENGTH_DELIMITED, PROTO_TEXT",
__func__);
break;
case envoy::config::tap::v3::OutputSink::PROTO_TEXT:
FALLTHRU;
case envoy::config::tap::v3::OutputSink::JSON_BODY_AS_BYTES:
FALLTHRU;
case envoy::config::tap::v3::OutputSink::JSON_BODY_AS_STRING: {
if (!parent_.isUdpPacketWriterCreated()) {
ENVOY_LOG_MISC(debug, "{}: udp writter isn't created yet", __func__);
break;
}
std::string json_string = MessageUtil::getJsonStringFromMessageOrError(*trace, true, false);
std::string json_string;
if (format == envoy::config::tap::v3::OutputSink::PROTO_TEXT) {
json_string = MessageUtil::MessageUtil::toTextProto(*trace);
} else {
json_string = MessageUtil::getJsonStringFromMessageOrError(*trace, true, false);
}
Buffer::OwnedImpl udp_data(std::move(json_string));
Api::IoCallUint64Result write_result =
parent_.udp_packet_writer_->writePacket(udp_data, nullptr, *parent_.udp_server_address_);
Expand Down

0 comments on commit 88e8ccc

Please sign in to comment.