-
Notifications
You must be signed in to change notification settings - Fork 5.3k
stream_info: cleaning up setters and getters #19139
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6edc58e
stream_info: cleaning up setters
alyssawilk abae1f6
Removing getters too
alyssawilk d66bc6e
more cleanup
alyssawilk 2f2c4d4
Merge branch 'main' into upstream3
alyssawilk a42a254
test fix
alyssawilk a72e8e5
tidy
alyssawilk 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -690,23 +690,27 @@ StreamInfoFormatter::StreamInfoFormatter(const std::string& field_name) { | |||||
| if (field_name == "REQUEST_DURATION") { | ||||||
| field_extractor_ = std::make_unique<StreamInfoDurationFieldExtractor>( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) { | ||||||
| return stream_info.lastDownstreamRxByteReceived(); | ||||||
| StreamInfo::TimingUtility timing(stream_info); | ||||||
| return timing.lastDownstreamRxByteReceived(); | ||||||
| }); | ||||||
| } else if (field_name == "REQUEST_TX_DURATION") { | ||||||
| field_extractor_ = std::make_unique<StreamInfoDurationFieldExtractor>( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) { | ||||||
| return stream_info.lastUpstreamTxByteSent(); | ||||||
| StreamInfo::TimingUtility timing(stream_info); | ||||||
| return timing.lastUpstreamTxByteSent(); | ||||||
| }); | ||||||
| } else if (field_name == "RESPONSE_DURATION") { | ||||||
| field_extractor_ = std::make_unique<StreamInfoDurationFieldExtractor>( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) { | ||||||
| return stream_info.firstUpstreamRxByteReceived(); | ||||||
| StreamInfo::TimingUtility timing(stream_info); | ||||||
| return timing.firstUpstreamRxByteReceived(); | ||||||
| }); | ||||||
| } else if (field_name == "RESPONSE_TX_DURATION") { | ||||||
| field_extractor_ = std::make_unique<StreamInfoDurationFieldExtractor>( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) { | ||||||
| auto downstream = stream_info.lastDownstreamTxByteSent(); | ||||||
| auto upstream = stream_info.firstUpstreamRxByteReceived(); | ||||||
| StreamInfo::TimingUtility timing(stream_info); | ||||||
| auto downstream = timing.lastDownstreamTxByteSent(); | ||||||
| auto upstream = timing.firstUpstreamRxByteReceived(); | ||||||
|
|
||||||
| absl::optional<std::chrono::nanoseconds> result; | ||||||
| if (downstream && upstream) { | ||||||
|
|
@@ -790,9 +794,13 @@ StreamInfoFormatter::StreamInfoFormatter(const std::string& field_name) { | |||||
| return StreamInfo::ResponseFlagUtils::toShortString(stream_info); | ||||||
| }); | ||||||
| } else if (field_name == "UPSTREAM_HOST") { | ||||||
| field_extractor_ = | ||||||
| StreamInfoAddressFieldExtractor::withPort([](const StreamInfo::StreamInfo& stream_info) { | ||||||
| return stream_info.upstreamHost() ? stream_info.upstreamHost()->address() : nullptr; | ||||||
| field_extractor_ = StreamInfoAddressFieldExtractor::withPort( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) | ||||||
| -> std::shared_ptr<const Envoy::Network::Address::Instance> { | ||||||
| if (stream_info.upstreamInfo() && stream_info.upstreamInfo()->upstreamHost()) { | ||||||
| return stream_info.upstreamInfo()->upstreamHost()->address(); | ||||||
| } | ||||||
| return nullptr; | ||||||
| }); | ||||||
| } else if (field_name == "UPSTREAM_CLUSTER") { | ||||||
| field_extractor_ = std::make_unique<StreamInfoStringFieldExtractor>( | ||||||
|
|
@@ -814,9 +822,13 @@ StreamInfoFormatter::StreamInfoFormatter(const std::string& field_name) { | |||||
| : absl::make_optional<std::string>(upstream_cluster_name); | ||||||
| }); | ||||||
| } else if (field_name == "UPSTREAM_LOCAL_ADDRESS") { | ||||||
| field_extractor_ = | ||||||
| StreamInfoAddressFieldExtractor::withPort([](const StreamInfo::StreamInfo& stream_info) { | ||||||
| return stream_info.upstreamLocalAddress(); | ||||||
| field_extractor_ = StreamInfoAddressFieldExtractor::withPort( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) | ||||||
| -> std::shared_ptr<const Envoy::Network::Address::Instance> { | ||||||
| if (stream_info.upstreamInfo().has_value()) { | ||||||
| return stream_info.upstreamInfo().value().get().upstreamLocalAddress(); | ||||||
|
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. Nit: small simplification, since OptRef already has a method for this chain of calls.
Suggested change
|
||||||
| } | ||||||
| return nullptr; | ||||||
| }); | ||||||
| } else if (field_name == "UPSTREAM_REQUEST_ATTEMPT_COUNT") { | ||||||
| field_extractor_ = std::make_unique<StreamInfoUInt64FieldExtractor>( | ||||||
|
|
@@ -942,8 +954,9 @@ StreamInfoFormatter::StreamInfoFormatter(const std::string& field_name) { | |||||
| field_extractor_ = std::make_unique<StreamInfoStringFieldExtractor>( | ||||||
| [](const StreamInfo::StreamInfo& stream_info) { | ||||||
| absl::optional<std::string> result; | ||||||
| if (!stream_info.upstreamTransportFailureReason().empty()) { | ||||||
| result = stream_info.upstreamTransportFailureReason(); | ||||||
| if (stream_info.upstreamInfo().has_value() && | ||||||
| !stream_info.upstreamInfo().value().get().upstreamTransportFailureReason().empty()) { | ||||||
| result = stream_info.upstreamInfo().value().get().upstreamTransportFailureReason(); | ||||||
| } | ||||||
| return result; | ||||||
| }); | ||||||
|
|
||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR seems quite similar to #19118? Does this PR replace that one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, theoretically. there's 2 issues with that one - the clang tidy which I have fixed locally (not pushed) and the windows build failure, which I could not figure out. I was hoping removing the getters would remove the build failure but left it assigned my way until I was sure.
if it's too big to combine getter and setter clean up, I can likely submit removing getters first, but didn't want to break it up until 1) I knew it fixed the problem and 2) checking to see if you wanted it split or were OK with the one large PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach seems totally fine. No need to split. It's a lot of movement but it's largely mechanical/straightforward. It's not like there's lots of complex interactions which are changing, I think.