-
Notifications
You must be signed in to change notification settings - Fork 5.5k
quic: add QUIC downstream connection close error stats. #16584
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
Changes from 12 commits
b7b52e1
a704f7d
e77ca28
1b9275b
a47dc19
c4394c5
71f28c3
a71c23c
79e200b
8957117
5c83f5f
6cd0d83
4fe3fc5
ac867ce
d009105
832b098
8b7047a
0cc03f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,12 @@ the following statistics: | |
| Per listener statistics | ||
| ----------------------- | ||
|
|
||
| Additional per listener statistics are rooted at *listener.<address>.http.<stat_prefix>.* with the | ||
| Per listener statistics are rooted at *listener.<address>. | ||
|
|
||
| Http per listener statistics | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Additional HTTP statistics are of the form http.<stat_prefix>.* with the | ||
| following statistics: | ||
|
|
||
| .. csv-table:: | ||
|
|
@@ -101,12 +106,24 @@ following statistics: | |
| downstream_rq_4xx, Counter, Total 4xx responses | ||
| downstream_rq_5xx, Counter, Total 5xx responses | ||
|
|
||
| Http3 per listener statistics | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Http3 statistics with the form of http3.<stat_prefix>.*: | ||
|
|
||
| .. csv-table:: | ||
| :header: Name, Type, Description | ||
| :widths: 1, 1, 2 | ||
|
|
||
| [direction].[source].quic_connection_close_error_code_[error_code], Counter, A collection of counters that are lazily initialized to record each quic connection close error code that's present. direction could be *upstream* or *downstream*. source could be *self* or *peer*. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're doccing up listener stats, won't direction always be downstream? And actually I hate to catch this now, but probably rather than self/peer it should be tx/rx for consistency with other Envoy stats. I find self and peer more intuitive (maybe 'cause that's what I'm used to) but I think most of the other stats (like resets tx_reset/rx_reset) are documented that way with tx for things sent to the peer and rx being codes received from the peer.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. The listener stats should be all downstreams. I haven't figured out the details on upstream stats. So I will update the doc again when I add them. Done changing names to tx/rx. |
||
|
|
||
|
|
||
| .. _config_http_conn_man_stats_per_codec: | ||
|
|
||
| Per codec statistics | ||
| ----------------------- | ||
|
|
||
| Each codec has the option of adding per-codec statistics. Both http1 and http2 have codec stats. | ||
| Each codec has the option of adding per-codec statistics. http1, http2, and http3 all have codec stats. | ||
|
|
||
| Http1 codec statistics | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #include "common/quic/quic_stat_names.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Quic { | ||
|
|
||
| // TODO(renjietang): Currently these stats are only available in downstream. Wire it up to upstream | ||
| // QUIC also. | ||
|
Comment on lines
+6
to
+7
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a quick read through it's not clear to me that this won't create an unbounded number of stats controlled by downstream (for exampled if the name somehow has the code number in it and the client controls the codes). This is probably not the case, but can you add more comments about why this is safe for use with uncontrolled peers?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great point! Instead, I now added a check in QuicStatNames::chargeQuicConnectionCloseStats() to ignore out-of-range error_codes and log a warning. I will follow up to dig deeper into the quiche code and see if bad error code handling can be done earlier. |
||
| QuicStatNames::QuicStatNames(Stats::SymbolTable& symbol_table) | ||
| : stat_name_pool_(symbol_table), symbol_table_(symbol_table), | ||
| http3_prefix_(stat_name_pool_.add("http3")), downstream_(stat_name_pool_.add("downstream")), | ||
| upstream_(stat_name_pool_.add("upstream")), from_self_(stat_name_pool_.add("self")), | ||
| from_peer_(stat_name_pool_.add("peer")) { | ||
| // Preallocate most used counters | ||
| // Most popular in client initiated connection close. | ||
| connectionCloseStatName(quic::QUIC_NETWORK_IDLE_TIMEOUT); | ||
|
RenjieTang marked this conversation as resolved.
|
||
| // Most popular in server initiated connection close. | ||
| connectionCloseStatName(quic::QUIC_SILENT_IDLE_TIMEOUT); | ||
| } | ||
|
|
||
| void QuicStatNames::incCounter(Stats::Scope& scope, const Stats::StatNameVec& names) { | ||
| Stats::SymbolTable::StoragePtr stat_name_storage = symbol_table_.join(names); | ||
|
RenjieTang marked this conversation as resolved.
|
||
| scope.counterFromStatName(Stats::StatName(stat_name_storage.get())).inc(); | ||
| } | ||
|
|
||
| void QuicStatNames::chargeQuicConnectionCloseStats(Stats::Scope& scope, | ||
| quic::QuicErrorCode error_code, | ||
| quic::ConnectionCloseSource source, | ||
| bool is_upstream) { | ||
| ASSERT(&symbol_table_ == &scope.symbolTable()); | ||
|
|
||
| const Stats::StatName connection_close = connectionCloseStatName(error_code); | ||
| incCounter(scope, {http3_prefix_, is_upstream ? upstream_ : downstream_, | ||
| source == quic::ConnectionCloseSource::FROM_SELF ? from_self_ : from_peer_, | ||
| connection_close}); | ||
| } | ||
|
|
||
| Stats::StatName QuicStatNames::connectionCloseStatName(quic::QuicErrorCode error_code) { | ||
| ASSERT(error_code < quic::QUIC_LAST_ERROR); | ||
|
|
||
| return Stats::StatName( | ||
| connection_error_stat_names_.get(error_code, [this, error_code]() -> const uint8_t* { | ||
| return stat_name_pool_.addReturningStorage( | ||
| absl::StrCat("quic_connection_close_error_code_", QuicErrorCodeToString(error_code))); | ||
| })); | ||
| } | ||
|
|
||
| } // namespace Quic | ||
| } // namespace Envoy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/stats/scope.h" | ||
|
|
||
| #include "common/common/thread.h" | ||
| #include "common/stats/symbol_table_impl.h" | ||
|
|
||
| #include "quiche/quic/core/quic_error_codes.h" | ||
| #include "quiche/quic/core/quic_types.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Quic { | ||
|
|
||
| class QuicStatNames { | ||
| public: | ||
| // This class holds lazily symbolized stat names and is responsible for charging them. | ||
| explicit QuicStatNames(Stats::SymbolTable& symbol_table); | ||
|
|
||
| void chargeQuicConnectionCloseStats(Stats::Scope& scope, quic::QuicErrorCode error_code, | ||
| quic::ConnectionCloseSource source, bool is_upstream); | ||
|
|
||
| private: | ||
| // Find the actual counter in |scope| and increment it. | ||
| // An example counter name: "downstream.self.quic_connection_close_error_code_QUIC_NO_ERROR". | ||
| void incCounter(Stats::Scope& scope, const Stats::StatNameVec& names); | ||
|
|
||
| Stats::StatName connectionCloseStatName(quic::QuicErrorCode error_code); | ||
|
|
||
| Stats::StatNamePool stat_name_pool_; | ||
| Stats::SymbolTable& symbol_table_; | ||
| const Stats::StatName http3_prefix_; | ||
| const Stats::StatName downstream_; | ||
| const Stats::StatName upstream_; | ||
|
alyssawilk marked this conversation as resolved.
|
||
| const Stats::StatName from_self_; | ||
| const Stats::StatName from_peer_; | ||
| Thread::AtomicPtrArray<const uint8_t, quic::QUIC_LAST_ERROR, | ||
| Thread::AtomicPtrAllocMode::DoNotDelete> | ||
| connection_error_stat_names_; | ||
| }; | ||
|
|
||
| } // namespace Quic | ||
| } // namespace Envoy | ||
Uh oh!
There was an error while loading. Please reload this page.