diff --git a/quic/api/QuicTransportBase.cpp b/quic/api/QuicTransportBase.cpp index 3da05b0fa..487e74f2d 100644 --- a/quic/api/QuicTransportBase.cpp +++ b/quic/api/QuicTransportBase.cpp @@ -2925,6 +2925,9 @@ QuicTransportBase::setStreamPriority( // It's not an error to prioritize a stream after it's sent its FIN - this // can reprioritize retransmissions. conn_->streamManager->setStreamPriority(id, level, incremental); + if (conn_->qLogger) { + conn_->qLogger->addPriorityUpdate(id, level, incremental); + } return folly::unit; } diff --git a/quic/logging/FileQLogger.cpp b/quic/logging/FileQLogger.cpp index 6a035050d..7ebfa7f01 100644 --- a/quic/logging/FileQLogger.cpp +++ b/quic/logging/FileQLogger.cpp @@ -441,6 +441,16 @@ void FileQLogger::addPathValidationEvent(bool success) { success, vantagePoint, refTime)); } +void FileQLogger::addPriorityUpdate( + quic::StreamId streamId, + uint8_t urgency, + bool incremental) { + auto refTime = std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()); + handleEvent(std::make_unique( + streamId, urgency, incremental, refTime)); +} + void FileQLogger::outputLogsToFile(const std::string& path, bool prettyJson) { if (streaming_) { return; diff --git a/quic/logging/FileQLogger.h b/quic/logging/FileQLogger.h index 30d5ec8b7..c50b3cee9 100644 --- a/quic/logging/FileQLogger.h +++ b/quic/logging/FileQLogger.h @@ -112,6 +112,10 @@ class FileQLogger : public BaseQLogger { override; virtual void addConnectionMigrationUpdate(bool intentionalMigration) override; virtual void addPathValidationEvent(bool success) override; + void addPriorityUpdate( + quic::StreamId streamId, + uint8_t urgency, + bool incremental) override; void outputLogsToFile(const std::string& path, bool prettyJson); folly::dynamic toDynamic() const; diff --git a/quic/logging/QLogger.h b/quic/logging/QLogger.h index ea1803946..b74d5b6da 100644 --- a/quic/logging/QLogger.h +++ b/quic/logging/QLogger.h @@ -110,6 +110,11 @@ class QLogger { folly::Optional timeSinceStreamCreation) = 0; virtual void addConnectionMigrationUpdate(bool intentionalMigration) = 0; virtual void addPathValidationEvent(bool success) = 0; + virtual void addPriorityUpdate( + quic::StreamId streamId, + uint8_t urgency, + bool incremental) = 0; + virtual void setDcid(folly::Optional connID) = 0; virtual void setScid(folly::Optional connID) = 0; }; diff --git a/quic/logging/QLoggerTypes.cpp b/quic/logging/QLoggerTypes.cpp index ff0600d84..d9e978d6f 100644 --- a/quic/logging/QLoggerTypes.cpp +++ b/quic/logging/QLoggerTypes.cpp @@ -839,6 +839,28 @@ folly::dynamic QLogPathValidationEvent::toDynamic() const { return d; } +QLogPriorityUpdateEvent::QLogPriorityUpdateEvent( + StreamId streamId, + uint8_t urgency, + bool incremental, + std::chrono::microseconds refTimeIn) + : streamId_(streamId), urgency_(urgency), incremental_(incremental) { + eventType = QLogEventType::PriorityUpdate; + refTime = refTimeIn; +} + +folly::dynamic QLogPriorityUpdateEvent::toDynamic() const { + folly::dynamic d = folly::dynamic::array( + folly::to(refTime.count()), "HTTP3", toString(eventType)); + folly::dynamic data = folly::dynamic::object(); + + data["id"] = streamId_; + data["urgency"] = urgency_; + data["incremental"] = incremental_; + d.push_back(std::move(data)); + return d; +} + folly::StringPiece toString(QLogEventType type) { switch (type) { case QLogEventType::PacketSent: @@ -883,6 +905,8 @@ folly::StringPiece toString(QLogEventType type) { return "connection_migration"; case QLogEventType::PathValidation: return "path_validation"; + case QLogEventType::PriorityUpdate: + return "priority"; } folly::assume_unreachable(); } diff --git a/quic/logging/QLoggerTypes.h b/quic/logging/QLoggerTypes.h index bd5c8edbe..d14573d91 100644 --- a/quic/logging/QLoggerTypes.h +++ b/quic/logging/QLoggerTypes.h @@ -334,7 +334,8 @@ enum class QLogEventType : uint32_t { AppLimitedUpdate, BandwidthEstUpdate, ConnectionMigration, - PathValidation + PathValidation, + PriorityUpdate }; folly::StringPiece toString(QLogEventType type); @@ -670,4 +671,21 @@ class QLogPathValidationEvent : public QLogEvent { VantagePoint vantagePoint_; }; +class QLogPriorityUpdateEvent : public QLogEvent { + public: + explicit QLogPriorityUpdateEvent( + StreamId id, + uint8_t urgency, + bool incremental, + std::chrono::microseconds refTimeIn); + ~QLogPriorityUpdateEvent() override = default; + + folly::dynamic toDynamic() const override; + + private: + StreamId streamId_; + uint8_t urgency_; + bool incremental_; +}; + } // namespace quic diff --git a/quic/logging/test/Mocks.h b/quic/logging/test/Mocks.h index 4789076fc..fd149ea64 100644 --- a/quic/logging/test/Mocks.h +++ b/quic/logging/test/Mocks.h @@ -75,5 +75,6 @@ class MockQLogger : public QLogger { MOCK_METHOD1(addPathValidationEvent, void(bool)); MOCK_METHOD1(setDcid, void(folly::Optional)); MOCK_METHOD1(setScid, void(folly::Optional)); + MOCK_METHOD3(addPriorityUpdate, void(quic::StreamId, uint8_t, bool)); }; } // namespace quic::test