forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quic: add QUIC downstream connection close error stats. (envoyproxy#1…
…6584) Signed-off-by: Renjie Tang <renjietang@google.com>
- Loading branch information
1 parent
beefb41
commit 290f241
Showing
18 changed files
with
287 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#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. | ||
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("tx")), | ||
from_peer_(stat_name_pool_.add("rx")) { | ||
// Preallocate most used counters | ||
// Most popular in client initiated connection close. | ||
connectionCloseStatName(quic::QUIC_NETWORK_IDLE_TIMEOUT); | ||
// 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); | ||
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()); | ||
|
||
if (error_code > quic::QUIC_LAST_ERROR) { | ||
error_code = quic::QUIC_LAST_ERROR; | ||
} | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "http3.downstream.tx.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_; | ||
const Stats::StatName from_self_; | ||
const Stats::StatName from_peer_; | ||
Thread::AtomicPtrArray<const uint8_t, quic::QUIC_LAST_ERROR + 1, | ||
Thread::AtomicPtrAllocMode::DoNotDelete> | ||
connection_error_stat_names_; | ||
}; | ||
|
||
} // namespace Quic | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.