Skip to content

Commit

Permalink
Add stats for control messages rate limited
Browse files Browse the repository at this point in the history
Summary: We're adding a counter that's bumped when we drop a control message (pings, settings, priorities, resets)

Reviewed By: afrind, lnicco

Differential Revision: D49616270

fbshipit-source-id: ad8a2b6162c5fbcf9935f01510d6438d569feaf0
  • Loading branch information
Aman Sharma authored and facebook-github-bot committed Sep 29, 2023
1 parent e230e7f commit 572c681
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion proxygen/lib/http/codec/ControlMessageRateLimitFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class ControlMessageRateLimitFilter : public PassThroughHTTPCodecFilter {
HTTPSessionStats* httpSessionStats)
: resetControlMessages_(numControlMsgsInCurrentInterval_,
httpSessionStats),
timer_(timer) {
timer_(timer),
httpSessionStats_(httpSessionStats) {
}

void setSessionStats(HTTPSessionStats* httpSessionStats) {
httpSessionStats_ = httpSessionStats;
resetControlMessages_.httpSessionStats = httpSessionStats;
}

Expand Down Expand Up @@ -117,6 +119,9 @@ class ControlMessageRateLimitFilter : public PassThroughHTTPCodecFilter {
}

if (++numControlMsgsInCurrentInterval_ > maxControlMsgsPerInterval_) {
if (httpSessionStats_) {
httpSessionStats_->recordControlMsgRateLimited();
}
HTTPException ex(
HTTPException::Direction::INGRESS_AND_EGRESS,
folly::to<std::string>(
Expand Down Expand Up @@ -199,6 +204,7 @@ class ControlMessageRateLimitFilter : public PassThroughHTTPCodecFilter {
ResetCounterTimeout resetDirectErrors_{
numDirectErrorHandlingInCurrentInterval_};
folly::HHWheelTimer* timer_{nullptr};
HTTPSessionStats* httpSessionStats_{nullptr};
};

} // namespace proxygen
2 changes: 2 additions & 0 deletions proxygen/lib/http/session/HTTPSessionStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class HTTPSessionStats : public TTLBAStats {

virtual void recordControlMsgsInInterval(int64_t) noexcept {
}
virtual void recordControlMsgRateLimited() noexcept {
}
};

} // namespace proxygen
6 changes: 6 additions & 0 deletions proxygen/lib/http/stats/ThreadLocalHTTPSessionStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ TLHTTPSessionStats::TLHTTPSessionStats(const std::string& prefix)
ttbtxTimeout(prefix + "_ttbtx_timeout", facebook::fb303::SUM),
ttbtxNotFound(prefix + "_ttbtx_not_found", facebook::fb303::SUM),
ttbtxExceedLimit(prefix + "_ttbtx_exceed_limit", facebook::fb303::SUM),
ctrlMsgsRateLimited(prefix + "_ctrl_msgs_rate_limited",
facebook::fb303::SUM),
txnsPerSession(prefix + "_txn_per_session",
1,
0,
Expand Down Expand Up @@ -166,4 +168,8 @@ void TLHTTPSessionStats::recordControlMsgsInInterval(
ctrlMsgsInInterval.add(quantity);
}

void TLHTTPSessionStats::recordControlMsgRateLimited() noexcept {
ctrlMsgsRateLimited.add(1);
}

} // namespace proxygen
2 changes: 2 additions & 0 deletions proxygen/lib/http/stats/ThreadLocalHTTPSessionStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TLHTTPSessionStats : public HTTPSessionStats {
void recordSessionPeriodicPingProbeTimeout() noexcept override;

void recordControlMsgsInInterval(int64_t quantity) noexcept override;
void recordControlMsgRateLimited() noexcept override;

BaseStats::TLCounter txnsOpen;
BaseStats::TLCounter pendingBufferedReadBytes;
Expand All @@ -66,6 +67,7 @@ class TLHTTPSessionStats : public HTTPSessionStats {
BaseStats::TLTimeseries ttbtxTimeout;
BaseStats::TLTimeseries ttbtxNotFound;
BaseStats::TLTimeseries ttbtxExceedLimit;
BaseStats::TLTimeseries ctrlMsgsRateLimited;
BaseStats::TLHistogram txnsPerSession;
BaseStats::TLHistogram sessionIdleTime;
BaseStats::TLHistogram ctrlMsgsInInterval;
Expand Down

0 comments on commit 572c681

Please sign in to comment.