Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add histogram for maximum concurrent requests per connection #12241

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/common/http/http2/codec_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ ConnectionImpl::~ConnectionImpl() {
stream->destroy();
}
nghttp2_session_del(session_);
stats_.cx_max_concurrent_streams_.recordValue(max_concurrent_streams_);
}

Http::Status ConnectionImpl::dispatch(Buffer::Instance& data) {
Expand Down Expand Up @@ -1253,6 +1254,8 @@ RequestEncoder& ClientConnectionImpl::newStream(ResponseDecoder& decoder) {
}
ClientStreamImpl& stream_ref = *stream;
stream->moveIntoList(std::move(stream), active_streams_);
max_concurrent_streams_ =
std::max(max_concurrent_streams_, static_cast<uint32_t>(active_streams_.size()));
return stream_ref;
}

Expand Down Expand Up @@ -1319,6 +1322,8 @@ int ServerConnectionImpl::onBeginHeaders(const nghttp2_frame* frame) {
stream->request_decoder_ = &callbacks_.newStream(*stream);
stream->stream_id_ = frame->hd.stream_id;
stream->moveIntoList(std::move(stream), active_streams_);
max_concurrent_streams_ =
std::max(max_concurrent_streams_, static_cast<uint32_t>(active_streams_.size()));
nghttp2_session_set_stream_user_data(session_, frame->hd.stream_id,
active_streams_.front().get());
return 0;
Expand Down
1 change: 1 addition & 0 deletions source/common/http/http2/codec_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ class ConnectionImpl : public virtual Connection, protected Logger::Loggable<Log
const uint32_t max_headers_kb_;
const uint32_t max_headers_count_;
uint32_t per_stream_buffer_limit_;
uint32_t max_concurrent_streams_;
bool allow_metadata_;
const bool stream_error_on_invalid_http_messaging_;
bool flood_detected_;
Expand Down
10 changes: 6 additions & 4 deletions source/common/http/http2/codec_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Http2 {
/**
* All stats for the HTTP/2 codec. @see stats_macros.h
*/
#define ALL_HTTP2_CODEC_STATS(COUNTER, GAUGE) \
#define ALL_HTTP2_CODEC_STATS(COUNTER, GAUGE, HISTOGRAM) \
COUNTER(dropped_headers_with_underscores) \
COUNTER(header_overflow) \
COUNTER(headers_cb_no_stream) \
Expand All @@ -29,7 +29,8 @@ namespace Http2 {
COUNTER(tx_flush_timeout) \
COUNTER(tx_reset) \
GAUGE(streams_active, Accumulate) \
GAUGE(pending_send_bytes, Accumulate)
GAUGE(pending_send_bytes, Accumulate) \
HISTOGRAM(cx_max_concurrent_streams, Unspecified)

/**
* Wrapper struct for the HTTP/2 codec stats. @see stats_macros.h
Expand All @@ -40,11 +41,12 @@ struct CodecStats {
static CodecStats& atomicGet(AtomicPtr& ptr, Stats::Scope& scope) {
return *ptr.get([&scope]() -> CodecStats* {
return new CodecStats{ALL_HTTP2_CODEC_STATS(POOL_COUNTER_PREFIX(scope, "http2."),
POOL_GAUGE_PREFIX(scope, "http2."))};
POOL_GAUGE_PREFIX(scope, "http2."),
POOL_HISTOGRAM_PREFIX(scope, "http2."))};
});
}

ALL_HTTP2_CODEC_STATS(GENERATE_COUNTER_STRUCT, GENERATE_GAUGE_STRUCT)
ALL_HTTP2_CODEC_STATS(GENERATE_COUNTER_STRUCT, GENERATE_GAUGE_STRUCT, GENERATE_HISTOGRAM_STRUCT)
};

} // namespace Http2
Expand Down