Skip to content

Make round trip time accessible through streaminfo - #24656

Merged
ggreenway merged 6 commits into
envoyproxy:mainfrom
DiazAlan:roundTripTime
Jan 30, 2023
Merged

ggreenway merged 6 commits into
envoyproxy:mainfrom
DiazAlan:roundTripTime

Conversation

@DiazAlan

Copy link
Copy Markdown
Contributor

Signed-off-by: AlanDiaz [email protected]

Commit Message: Make round trip time accessible through stream info
Additional Description: Make the last round trip time of the previous handshake accessible through stream info. This will allow us to make it accessible in access logs,
Risk Level: Low
Testing: Added an integration test in filter integration test that adds roundtriptime to the header and checks if it exists
Docs Changes: NA
Release Notes: NA
Platform Specific Features: NA
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #24656 was opened by DiazAlan.

see: more, trace.

@DiazAlan

DiazAlan commented Jan 4, 2023

Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:

🐱

Caused by: a #24656 (comment) was created by @DiazAlan.

see: more, trace.

Resolving merge conflict
Signed-off-by: AlanDiaz <[email protected]>
@DiazAlan
DiazAlan marked this pull request as ready for review January 5, 2023 15:36
@DiazAlan
DiazAlan requested a review from ggreenway as a code owner January 5, 2023 15:36

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to expose this, but I'm not sure if it's a good idea to latch the value right after the connection is setup. At least on linux, the TCP_INFO syscall that provides this provides a smoothed RTT, and it may not be very smoothed right after connection setup (very few round trips at that point). Also, the RTT can vary over the life of the connection. If this is being logged on a specific http connection, we'd want to sample the RTT near-in-time to when that particular request happened. Maybe it would make more sense to latch this in Http::StreamDecoderFilter::onStreamComplete() or near that time.

/wait-any

@ggreenway ggreenway self-assigned this Jan 5, 2023
@yanavlasov yanavlasov self-assigned this Jan 5, 2023
Comment thread envoy/network/socket.h
virtual void setJA3Hash(const absl::string_view ja3_hash) PURE;

/**
* @param milliseconds of round trip time of previous connection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it previous?

@yanavlasov

Copy link
Copy Markdown
Contributor

I think it makes sense to expose this, but I'm not sure if it's a good idea to latch the value right after the connection is setup. At least on linux, the TCP_INFO syscall that provides this provides a smoothed RTT, and it may not be very smoothed right after connection setup (very few round trips at that point). Also, the RTT can vary over the life of the connection. If this is being logged on a specific http connection, we'd want to sample the RTT near-in-time to when that particular request happened. Maybe it would make more sense to latch this in Http::StreamDecoderFilter::onStreamComplete() or near that time.

/wait-any

It makes sense. The eventual goal is to log the RTT in the access log. I agree that ideally it should be done at the end of the HTTP request or TCP connection, right before access log is to be emitted. We will need to deal with the fact that H/1 requests can be framed be connection closure and at this point RTT may not be available but this may be too far of an edge case.

Would it be ok if these additional samples are implemented in a follow-up PR, to make it easier to iterate on this change?

@ggreenway

Copy link
Copy Markdown
Member

Would it be ok if these additional samples are implemented in a follow-up PR, to make it easier to iterate on this change?

I think a lot of the code in this PR will have to be changed/reverted to get to that solution, so if we agree that we should change to sampling sometime during the request (beginning or end of request probably) then I'm not sure it makes sense to merge this as-is.

@yanavlasov

Copy link
Copy Markdown
Contributor

Would it be ok if these additional samples are implemented in a follow-up PR, to make it easier to iterate on this change?

I think a lot of the code in this PR will have to be changed/reverted to get to that solution, so if we agree that we should change to sampling sometime during the request (beginning or end of request probably) then I'm not sure it makes sense to merge this as-is.

Hmm, do you have a different approach for making RTT accessible in StreamInfo? I did not think we will need to change much, since both HCM or FilterManager or TCP proxy have access to the Network::Connection that had ConnectionInfoSetter and the ' lastRoundTripTime. It can be optimized a bit by adding the recordLastRoundTripTime` method to Network::Connection in the ConnectionInfoProvider, but I would not think we will need to redesign the existing code. We still want to record the RTT from TCP handshake in case connection fails right after that.

@ggreenway

Copy link
Copy Markdown
Member

Hmm, do you have a different approach for making RTT accessible in StreamInfo? I did not think we will need to change much, since both HCM or FilterManager or TCP proxy have access to the Network::Connection that had ConnectionInfoSetter and the ' lastRoundTripTime. It can be optimized a bit by adding the recordLastRoundTripTime` method to Network::Connection in the ConnectionInfoProvider, but I would not think we will need to redesign the existing code. We still want to record the RTT from TCP handshake in case connection fails right after that.

I agree that accessing it via stream_info through the ConnectionInfoProvider is the right place to put it. But when it is latched from a different place, the changes in this PR to proxy protocol tests and active_tcp_listener will need to be reverted, which by number-of-lines is about half of the PR.

ggreenway
ggreenway previously approved these changes Jan 12, 2023

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/wait

stream.completeRequest();

// Set roundtrip time in connectionInfoSetter before OnStreamComplete
absl::optional<std::chrono::milliseconds> t = read_callbacks_->connection().lastRoundTripTime();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test that validates this happens before log() is called.

@DiazAlan

Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #24656 (comment) was created by @DiazAlan.

see: more, trace.

Signed-off-by: AlanDiaz <[email protected]>
@ggreenway
ggreenway merged commit 938f682 into envoyproxy:main Jan 30, 2023
@DiazAlan
DiazAlan deleted the roundTripTime branch January 30, 2023 18:46
VishalDamgude pushed a commit to freshworks-oss/envoy that referenced this pull request Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants