From 65bc1417f34a08248dc06dd61f5b9540a4d0d04e Mon Sep 17 00:00:00 2001 From: Matt Joras Date: Tue, 5 Nov 2024 18:12:45 -0800 Subject: [PATCH] Add alpn to transport summary event Summary: As in title, useful. Reviewed By: kvtsoy Differential Revision: D65508296 fbshipit-source-id: f068611399797df4dd422828373b1ddbbceec7df --- quic/api/QuicTransportBaseLite.cpp | 3 ++- quic/logging/FileQLogger.cpp | 1 + quic/logging/QLogger.h | 1 + quic/logging/QLoggerTypes.cpp | 5 ++++- quic/logging/QLoggerTypes.h | 2 ++ quic/logging/test/QLoggerTest.cpp | 10 +++++++--- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/quic/api/QuicTransportBaseLite.cpp b/quic/api/QuicTransportBaseLite.cpp index 535c2c337..27211ee9f 100644 --- a/quic/api/QuicTransportBaseLite.cpp +++ b/quic/api/QuicTransportBaseLite.cpp @@ -1421,7 +1421,8 @@ void QuicTransportBaseLite::closeImpl( uint64_t(conn_->transportSettings.timeReorderingThreshDividend), conn_->usedZeroRtt, conn_->version.value_or(QuicVersion::MVFST_INVALID), - conn_->dsrPacketCount}); + conn_->dsrPacketCount, + getAppProtocol().value_or("")}); } // TODO: truncate the error code string to be 1MSS only. diff --git a/quic/logging/FileQLogger.cpp b/quic/logging/FileQLogger.cpp index 03339a122..5e4b35d87 100644 --- a/quic/logging/FileQLogger.cpp +++ b/quic/logging/FileQLogger.cpp @@ -250,6 +250,7 @@ void FileQLogger::addTransportSummary(const TransportSummaryArgs& args) { args.usedZeroRtt, args.quicVersion, args.dsrPacketCount, + std::move(args.alpn), refTime)); } diff --git a/quic/logging/QLogger.h b/quic/logging/QLogger.h index 17476ec92..5d3c2cc4a 100644 --- a/quic/logging/QLogger.h +++ b/quic/logging/QLogger.h @@ -71,6 +71,7 @@ class QLogger { bool usedZeroRtt{}; QuicVersion quicVersion{QuicVersion::MVFST_INVALID}; uint64_t dsrPacketCount{}; + std::string alpn; }; virtual void addTransportSummary(const TransportSummaryArgs& args) = 0; virtual void addCongestionMetricUpdate( diff --git a/quic/logging/QLoggerTypes.cpp b/quic/logging/QLoggerTypes.cpp index 626b0bfc6..0eb539881 100644 --- a/quic/logging/QLoggerTypes.cpp +++ b/quic/logging/QLoggerTypes.cpp @@ -423,6 +423,7 @@ QLogTransportSummaryEvent::QLogTransportSummaryEvent( bool usedZeroRttIn, QuicVersion quicVersionIn, uint64_t dsrPacketCountIn, + std::string alpnIn, std::chrono::microseconds refTimeIn) : totalBytesSent{totalBytesSentIn}, totalBytesRecvd{totalBytesRecvdIn}, @@ -442,7 +443,8 @@ QLogTransportSummaryEvent::QLogTransportSummaryEvent( finalPacketLossTimeReorderingThreshDividend}, usedZeroRtt{usedZeroRttIn}, quicVersion{quicVersionIn}, - dsrPacketCount{dsrPacketCountIn} { + dsrPacketCount{dsrPacketCountIn}, + alpn{alpnIn} { eventType = QLogEventType::TransportSummary; refTime = refTimeIn; } @@ -479,6 +481,7 @@ folly::dynamic QLogTransportSummaryEvent::toDynamic() const { static_cast::type>( quicVersion); data["dsr_packet_count"] = dsrPacketCount; + data["alpn"] = alpn; d.push_back(std::move(data)); return d; diff --git a/quic/logging/QLoggerTypes.h b/quic/logging/QLoggerTypes.h index d380d2ff3..bbf240eff 100644 --- a/quic/logging/QLoggerTypes.h +++ b/quic/logging/QLoggerTypes.h @@ -483,6 +483,7 @@ class QLogTransportSummaryEvent : public QLogEvent { bool usedZeroRtt, QuicVersion version, uint64_t dsrPacketCount, + std::string alpn, std::chrono::microseconds refTimeIn); ~QLogTransportSummaryEvent() override = default; uint64_t totalBytesSent; @@ -503,6 +504,7 @@ class QLogTransportSummaryEvent : public QLogEvent { bool usedZeroRtt; QuicVersion quicVersion; uint64_t dsrPacketCount; + std::string alpn; FOLLY_NODISCARD folly::dynamic toDynamic() const override; }; diff --git a/quic/logging/test/QLoggerTest.cpp b/quic/logging/test/QLoggerTest.cpp index b4d55542c..102691cde 100644 --- a/quic/logging/test/QLoggerTest.cpp +++ b/quic/logging/test/QLoggerTest.cpp @@ -116,7 +116,8 @@ TEST_F(QLoggerTest, TransportSummaryEvent) { 47, false, QuicVersion::MVFST, - 37}); + 37, + "blah"}); std::unique_ptr p = std::move(q.logs[0]); auto gotEvent = dynamic_cast(p.get()); @@ -138,6 +139,7 @@ TEST_F(QLoggerTest, TransportSummaryEvent) { EXPECT_EQ(gotEvent->finalPacketLossTimeReorderingThreshDividend, 47); EXPECT_EQ(gotEvent->usedZeroRtt, false); EXPECT_EQ(gotEvent->dsrPacketCount, 37); + EXPECT_EQ(gotEvent->alpn, "blah"); } TEST_F(QLoggerTest, CongestionMetricUpdateEvent) { @@ -856,7 +858,8 @@ TEST_F(QLoggerTest, TransportSummaryFollyDynamic) { "final_packet_loss_time_reordering_threshold_dividend": 15, "used_zero_rtt": true, "quic_version": 4207849474, - "dsr_packet_count": 37 + "dsr_packet_count": 37, + "alpn": "blah" } ] ])"); @@ -880,7 +883,8 @@ TEST_F(QLoggerTest, TransportSummaryFollyDynamic) { 15, true, QuicVersion::MVFST, - 37}); + 37, + "blah"}); folly::dynamic gotDynamic = q.toDynamic(); gotDynamic["traces"][0]["events"][0][0] = "0"; // hardcode reference time folly::dynamic gotEvents = gotDynamic["traces"][0]["events"];