Add stats for transport knobs
Summary:
This adds visibility over the transport knobs. Will be helpful when we add more knobs (e.g. canary token).
I'll remove them for the sake of storage once we're sure the plumbing works.
MODIFY
quic/samples/echo/LogQuicStats.h
quic/samples/echo/LogQuicStats.h
@@ -165,6 +165,16 @@ class LogQuicStats : public quic::QuicTransportStatsCallback {
VLOG(2) << prefix_ << "onConnectionPMTUUpperBoundDetected";
}
+ void onTransportKnobApplied(TransportKnobType knobType) override {
+ VLOG(2) << prefix_
+ << "onTransportKnobApplied knobType=" << toString(knobType);
+ }
+
+ void onTransportKnobError(TransportKnobType knobType) override {
+ VLOG(2) << prefix_
+ << "onTransportKnboError knobType=" << toString(knobType);
+ }
+
private:
std::string prefix_;
};

MODIFY
quic/server/QuicServerTransport.cpp
quic/server/QuicServerTransport.cpp
@@ -382,6 +382,15 @@ void QuicServerTransport::handleTransportKnobParams(
auto maybeParamHandler = transportKnobParamHandlers_.find(param.id);
if (maybeParamHandler != transportKnobParamHandlers_.end()) {
(maybeParamHandler->second)(serverConn_, param.val);
+ QUIC_STATS(
+ conn_->statsCallback,
+ onTransportKnobApplied,
+ QuicTransportStatsCallback::paramIdToTransportKnobType(param.id));
+ } else {
+ QUIC_STATS(
+ conn_->statsCallback,
+ onTransportKnobError,
+ QuicTransportStatsCallback::paramIdToTransportKnobType(param.id));
}
}
}
@@ -588,6 +597,11 @@ void QuicServerTransport::onTransportKnobs(Buf knobBlob) {
auto params = parseTransportKnobs(serializedKnobs);
if (params.hasValue()) {
handleTransportKnobParams(*params);
+ } else {
+ QUIC_STATS(
+ conn_->statsCallback,
+ onTransportKnobError,
+ QuicTransportStatsCallback::TransportKnobType::UNKNOWN);
}
}
}

MODIFY
quic/state/QuicTransportStatsCallback.h
quic/state/QuicTransportStatsCallback.h
@@ -67,6 +67,13 @@ class QuicTransportStatsCallback {
MAX
};
+ enum class TransportKnobType : uint8_t {
+ ZERO_PMTU_BLACKHOLE,
+ FORCIBLY_SET_UDP_PAYLOAD_SIZE,
+ UNKNOWN,
+ MAX
+ };
+
virtual ~QuicTransportStatsCallback() = default;
// packet level metrics
@@ -144,6 +151,10 @@ class QuicTransportStatsCallback {
virtual void onConnectionPMTUUpperBoundDetected() = 0;
+ virtual void onTransportKnobApplied(TransportKnobType knobType) = 0;
+
+ virtual void onTransportKnobError(TransportKnobType knobType) = 0;
+
static const char* toString(ConnectionCloseReason reason) {
switch (reason) {
case ConnectionCloseReason::NONE:
@@ -237,6 +248,34 @@ class QuicTransportStatsCallback {
return SocketErrorType::OTHER;
}
}
+
+ static const char* toString(TransportKnobType knobType) {
+ switch (knobType) {
+ case TransportKnobType::ZERO_PMTU_BLACKHOLE:
+ return "ZERO_PMTU_BLACKHOLE";
+ case TransportKnobType::FORCIBLY_SET_UDP_PAYLOAD_SIZE:
+ return "FORCIBLY_SET_UDP_PAYLOAD_SIZE";
+ case TransportKnobType::UNKNOWN:
+ return "UNKNOWN";
+ case TransportKnobType::MAX:
+ return "MAX";
+ default:
+ throw std::runtime_error("Undefined TransportKnobType passed");
+ }
+ }
+
+ static TransportKnobType paramIdToTransportKnobType(uint64_t paramId) {
+ switch (paramId) {
+ case static_cast<uint64_t>(
+ TransportKnobParamId::ZERO_PMTU_BLACKHOLE_DETECTION):
+ return TransportKnobType::ZERO_PMTU_BLACKHOLE;
+ case static_cast<uint64_t>(
+ TransportKnobParamId::FORCIBLY_SET_UDP_PAYLOAD_SIZE):
+ return TransportKnobType::FORCIBLY_SET_UDP_PAYLOAD_SIZE;
+ default:
+ return TransportKnobType::UNKNOWN;
+ }
+ }
};
/**

MODIFY
quic/state/test/MockQuicStats.h
quic/state/test/MockQuicStats.h
@@ -51,6 +51,8 @@ class MockQuicStats : public QuicTransportStatsCallback {
MOCK_METHOD0(onConnectionPMTURaised, void());
MOCK_METHOD0(onConnectionPMTUBlackholeDetected, void());
MOCK_METHOD0(onConnectionPMTUUpperBoundDetected, void());
+ MOCK_METHOD1(onTransportKnobApplied, void(TransportKnobType));
+ MOCK_METHOD1(onTransportKnobError, void(TransportKnobType));
};
class MockQuicStatsFactory : public QuicTransportStatsCallbackFactory {

Add stats for transport knobs

Summary:
This adds visibility over the transport knobs. Will be helpful when we add more knobs (e.g. canary token).

I'll remove them for the sake of storage once we're sure the plumbing works.

Reviewed By: avasylev

Differential Revision: D24929923

fbshipit-source-id: a64bb6e613f3a69a47bf9b32e8c31890ad1afdfc