-
Notifications
You must be signed in to change notification settings - Fork 5.4k
make ClusterInfo::traffic_stats_ a unique_ptr, so that later we can lazy-init it later. #24406
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
Merged
ggreenway
merged 14 commits into
envoyproxy:main
from
stevenzzzz:ClusterTrafficStats_unique_ptr
Dec 14, 2022
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fba6b7a
make ClusterInfo::traffic_stats_ a unique_ptr, so that later we can L…
stevenzzzz 803004f
revert some unwanted updates
stevenzzzz 74059e4
revert more unwanted updates
stevenzzzz fea4a48
heh, vscode is slower than git
stevenzzzz b69c02c
revert more unwanted updates
stevenzzzz 9de8e10
fixes for Josh comments
stevenzzzz 58ba476
re add the helper files
stevenzzzz 58bc7d5
Merge branch 'main' into ClusterTrafficStats_unique_ptr
stevenzzzz 150acb0
add comments for testing base classes.
stevenzzzz 98c167a
update alias
stevenzzzz d7bb525
move comment
stevenzzzz a1dfeb3
fix comment
stevenzzzz c543f83
Merge branch 'main' into ClusterTrafficStats_unique_ptr
stevenzzzz 79ce9bf
revert some unrelated changes that could be included in the next PR
stevenzzzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -135,7 +135,7 @@ ConnPoolImplBase::tryCreateNewConnection(float global_preconnect_ratio) { | |
| const bool can_create_connection = host_->canCreateConnection(priority_); | ||
|
|
||
| if (!can_create_connection) { | ||
| host_->cluster().trafficStats().upstream_cx_overflow_.inc(); | ||
| host_->cluster().trafficStats()->upstream_cx_overflow_.inc(); | ||
| } | ||
| // If we are at the connection circuit-breaker limit due to other upstreams having | ||
| // too many open connections, and this upstream has no connections, always create one, to | ||
|
|
@@ -167,15 +167,16 @@ void ConnPoolImplBase::attachStreamToClient(Envoy::ConnectionPool::ActiveClient& | |
| AttachContext& context) { | ||
| ASSERT(client.readyForStream()); | ||
|
|
||
| Upstream::ClusterTrafficStats& traffic_stats = *host_->cluster().trafficStats(); | ||
| if (client.state() == Envoy::ConnectionPool::ActiveClient::State::ReadyForEarlyData) { | ||
| host_->cluster().trafficStats().upstream_rq_0rtt_.inc(); | ||
| traffic_stats.upstream_rq_0rtt_.inc(); | ||
| } | ||
|
|
||
| if (enforceMaxRequests() && !host_->cluster().resourceManager(priority_).requests().canCreate()) { | ||
| ENVOY_LOG(debug, "max streams overflow"); | ||
| onPoolFailure(client.real_host_description_, absl::string_view(), | ||
| ConnectionPool::PoolFailureReason::Overflow, context); | ||
| host_->cluster().trafficStats().upstream_rq_pending_overflow_.inc(); | ||
| traffic_stats.upstream_rq_pending_overflow_.inc(); | ||
| return; | ||
| } | ||
| ENVOY_CONN_LOG(debug, "creating stream", client); | ||
|
|
@@ -185,7 +186,7 @@ void ConnPoolImplBase::attachStreamToClient(Envoy::ConnectionPool::ActiveClient& | |
| client.remaining_streams_--; | ||
| if (client.remaining_streams_ == 0) { | ||
| ENVOY_CONN_LOG(debug, "maximum streams per connection, start draining", client); | ||
| host_->cluster().trafficStats().upstream_cx_max_requests_.inc(); | ||
| traffic_stats.upstream_cx_max_requests_.inc(); | ||
| transitionActiveClientState(client, Envoy::ConnectionPool::ActiveClient::State::Draining); | ||
| } else if (capacity == 1) { | ||
| // As soon as the new stream is created, the client will be maxed out. | ||
|
|
@@ -202,8 +203,8 @@ void ConnPoolImplBase::attachStreamToClient(Envoy::ConnectionPool::ActiveClient& | |
| num_active_streams_++; | ||
| host_->stats().rq_total_.inc(); | ||
| host_->stats().rq_active_.inc(); | ||
| host_->cluster().trafficStats().upstream_rq_total_.inc(); | ||
| host_->cluster().trafficStats().upstream_rq_active_.inc(); | ||
| traffic_stats.upstream_rq_total_.inc(); | ||
| traffic_stats.upstream_rq_active_.inc(); | ||
| host_->cluster().resourceManager(priority_).requests().inc(); | ||
|
|
||
| onPoolReady(client, context); | ||
|
|
@@ -216,7 +217,7 @@ void ConnPoolImplBase::onStreamClosed(Envoy::ConnectionPool::ActiveClient& clien | |
| state_.decrActiveStreams(1); | ||
| num_active_streams_--; | ||
| host_->stats().rq_active_.dec(); | ||
| host_->cluster().trafficStats().upstream_rq_active_.dec(); | ||
| host_->cluster().trafficStats()->upstream_rq_active_.dec(); | ||
| host_->cluster().resourceManager(priority_).requests().dec(); | ||
| // We don't update the capacity for HTTP/3 as the stream count should only | ||
| // increase when a MAX_STREAMS frame is received. | ||
|
|
@@ -282,7 +283,7 @@ ConnectionPool::Cancellable* ConnPoolImplBase::newStreamImpl(AttachContext& cont | |
| ENVOY_LOG(debug, "max pending streams overflow"); | ||
| onPoolFailure(nullptr, absl::string_view(), ConnectionPool::PoolFailureReason::Overflow, | ||
| context); | ||
| host_->cluster().trafficStats().upstream_rq_pending_overflow_.inc(); | ||
| host_->cluster().trafficStats()->upstream_rq_pending_overflow_.inc(); | ||
| return nullptr; | ||
| } | ||
|
|
||
|
|
@@ -490,7 +491,7 @@ void ConnPoolImplBase::onConnectionEvent(ActiveClient& client, absl::string_view | |
|
|
||
| if (!client.hasHandshakeCompleted()) { | ||
| client.has_handshake_completed_ = true; | ||
| host_->cluster().trafficStats().upstream_cx_connect_fail_.inc(); | ||
| host_->cluster().trafficStats()->upstream_cx_connect_fail_.inc(); | ||
| host_->stats().cx_connect_fail_.inc(); | ||
|
|
||
| onConnectFailed(client); | ||
|
|
@@ -595,7 +596,7 @@ void ConnPoolImplBase::onConnectionEvent(ActiveClient& client, absl::string_view | |
| client.currentUnusedCapacity()); | ||
| // No need to update connecting capacity and connect_timer_ as the client is still connecting. | ||
| ASSERT(client.state() == ActiveClient::State::Connecting); | ||
| host()->cluster().trafficStats().upstream_cx_connect_with_0_rtt_.inc(); | ||
| host()->cluster().trafficStats()->upstream_cx_connect_with_0_rtt_.inc(); | ||
| transitionActiveClientState(client, (client.currentUnusedCapacity() > 0 | ||
| ? ActiveClient::State::ReadyForEarlyData | ||
| : ActiveClient::State::Busy)); | ||
|
|
@@ -606,13 +607,14 @@ void ConnPoolImplBase::onConnectionEvent(ActiveClient& client, absl::string_view | |
|
|
||
| PendingStream::PendingStream(ConnPoolImplBase& parent, bool can_send_early_data) | ||
| : parent_(parent), can_send_early_data_(can_send_early_data) { | ||
| parent_.host()->cluster().trafficStats().upstream_rq_pending_total_.inc(); | ||
| parent_.host()->cluster().trafficStats().upstream_rq_pending_active_.inc(); | ||
| Upstream::ClusterTrafficStats& traffic_stats = *parent_.host()->cluster().trafficStats(); | ||
| traffic_stats.upstream_rq_pending_total_.inc(); | ||
| traffic_stats.upstream_rq_pending_active_.inc(); | ||
| parent_.host()->cluster().resourceManager(parent_.priority()).pendingRequests().inc(); | ||
| } | ||
|
|
||
| PendingStream::~PendingStream() { | ||
| parent_.host()->cluster().trafficStats().upstream_rq_pending_active_.dec(); | ||
| parent_.host()->cluster().trafficStats()->upstream_rq_pending_active_.dec(); | ||
| parent_.host()->cluster().resourceManager(parent_.priority()).pendingRequests().dec(); | ||
| } | ||
|
|
||
|
|
@@ -630,7 +632,7 @@ void ConnPoolImplBase::purgePendingStreams( | |
| while (!pending_streams_to_purge_.empty()) { | ||
| PendingStreamPtr stream = | ||
| pending_streams_to_purge_.front()->removeFromList(pending_streams_to_purge_); | ||
| host_->cluster().trafficStats().upstream_rq_pending_failure_eject_.inc(); | ||
| host_->cluster().trafficStats()->upstream_rq_pending_failure_eject_.inc(); | ||
| onPoolFailure(host_description, failure_reason, reason, stream->context()); | ||
| } | ||
| } | ||
|
|
@@ -683,7 +685,7 @@ void ConnPoolImplBase::onPendingStreamCancel(PendingStream& stream, | |
| } | ||
| } | ||
|
|
||
| host_->cluster().trafficStats().upstream_rq_cancelled_.inc(); | ||
| host_->cluster().trafficStats()->upstream_rq_cancelled_.inc(); | ||
| checkForIdleAndCloseIdleConnsIfDraining(); | ||
| } | ||
|
|
||
|
|
@@ -757,16 +759,16 @@ ActiveClient::ActiveClient(ConnPoolImplBase& parent, uint32_t lifetime_stream_li | |
| concurrent_stream_limit_(translateZeroToUnlimited(concurrent_stream_limit)), | ||
| connect_timer_(parent_.dispatcher().createTimer([this]() { onConnectTimeout(); })) { | ||
| conn_connect_ms_ = std::make_unique<Stats::HistogramCompletableTimespanImpl>( | ||
| parent_.host()->cluster().trafficStats().upstream_cx_connect_ms_, | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_connect_ms_, | ||
| parent_.dispatcher().timeSource()); | ||
| conn_length_ = std::make_unique<Stats::HistogramCompletableTimespanImpl>( | ||
| parent_.host()->cluster().trafficStats().upstream_cx_length_ms_, | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_length_ms_, | ||
| parent_.dispatcher().timeSource()); | ||
| connect_timer_->enableTimer(parent_.host()->cluster().connectTimeout()); | ||
| parent_.host()->stats().cx_total_.inc(); | ||
| parent_.host()->stats().cx_active_.inc(); | ||
| parent_.host()->cluster().trafficStats().upstream_cx_total_.inc(); | ||
| parent_.host()->cluster().trafficStats().upstream_cx_active_.inc(); | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_total_.inc(); | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_active_.inc(); | ||
|
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. capture
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. Done |
||
| parent_.host()->cluster().resourceManager(parent_.priority()).connections().inc(); | ||
| } | ||
|
|
||
|
|
@@ -778,15 +780,15 @@ void ActiveClient::releaseResourcesBase() { | |
|
|
||
| conn_length_->complete(); | ||
|
|
||
| parent_.host()->cluster().trafficStats().upstream_cx_active_.dec(); | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_active_.dec(); | ||
| parent_.host()->stats().cx_active_.dec(); | ||
| parent_.host()->cluster().resourceManager(parent_.priority()).connections().dec(); | ||
| } | ||
| } | ||
|
|
||
| void ActiveClient::onConnectTimeout() { | ||
| ENVOY_CONN_LOG(debug, "connect timeout", *this); | ||
| parent_.host()->cluster().trafficStats().upstream_cx_connect_timeout_.inc(); | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_connect_timeout_.inc(); | ||
| timed_out_ = true; | ||
| close(); | ||
| } | ||
|
|
@@ -811,7 +813,7 @@ void ActiveClient::onConnectionDurationTimeout() { | |
| } | ||
|
|
||
| ENVOY_CONN_LOG(debug, "max connection duration reached, start draining", *this); | ||
| parent_.host()->cluster().trafficStats().upstream_cx_max_duration_reached_.inc(); | ||
| parent_.host()->cluster().trafficStats()->upstream_cx_max_duration_reached_.inc(); | ||
| parent_.transitionActiveClientState(*this, Envoy::ConnectionPool::ActiveClient::State::Draining); | ||
|
|
||
| // Close out the draining client if we no longer have active streams. | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.