-
Notifications
You must be signed in to change notification settings - Fork 5.5k
quic: deferred logging of roundtrip response time #23648
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 54 commits
e8a80ff
dd13f85
bebc3a2
a13b24f
ed44a5e
b9d9c14
e9da2a2
002cd98
4b2abad
e04f8ce
b63b4e0
acb45ba
3ba2841
c28cebf
888818c
7564cf0
d512366
3108180
33275d0
a605ccf
423b984
46aa544
c7bc1ac
d03985d
8424a37
21c64f6
51f2123
b5771a5
3ba8d59
d29a9b9
a3e30ca
e1490c7
c55f5b8
ca4d8f5
33e3be5
2b228cf
63205e5
9b31dcd
8257a37
f5f469f
613f1c3
8fc0384
826b143
148e199
f19f6f2
479f2b1
9faa827
39d9c7a
154ca1b
ecbb802
5b0aca1
82efea7
7c65613
fc87b2e
db5fe39
f3817ca
6ed652e
22b72f5
26f3cf4
fa2ddad
763f0b6
4dda7d1
e870fb9
fb91bee
0182d16
91e8aee
82096d6
4579a5a
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| #include <limits> | ||
| #include <memory> | ||
|
|
||
| #include "envoy/access_log/access_log.h" | ||
| #include "envoy/buffer/buffer.h" | ||
| #include "envoy/common/pure.h" | ||
| #include "envoy/grpc/status.h" | ||
|
|
@@ -174,6 +175,19 @@ class ResponseEncoder : public virtual StreamEncoder { | |
| * @param decoder new request decoder. | ||
| */ | ||
| virtual void setRequestDecoder(RequestDecoder& decoder) PURE; | ||
|
|
||
| /** | ||
| * Set headers, trailers, and stream info for deferred logging. | ||
| * @param request_header_map Request headers for this stream. | ||
| * @param response_header_map Response headers for this stream. | ||
| * @param response_trailer_map Response trailers for this stream. | ||
| * @param stream_info Stream info for this stream. | ||
| */ | ||
| virtual void | ||
| setDeferredLoggingHeadersAndTrailers(Http::RequestHeaderMapSharedPtr request_header_map, | ||
| Http::ResponseHeaderMapSharedPtr response_header_map, | ||
| Http::ResponseTrailerMapSharedPtr response_trailer_map, | ||
| StreamInfo::StreamInfo& stream_info) PURE; | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -211,7 +225,7 @@ class RequestDecoder : public virtual StreamDecoder { | |
| * @param headers supplies the decoded headers map. | ||
| * @param end_stream supplies whether this is a header only request. | ||
| */ | ||
| virtual void decodeHeaders(RequestHeaderMapPtr&& headers, bool end_stream) PURE; | ||
| virtual void decodeHeaders(RequestHeaderMapSharedPtr&& headers, bool end_stream) PURE; | ||
|
|
||
| /** | ||
| * Called with a decoded trailers frame. This implicitly ends the stream. | ||
|
|
@@ -236,6 +250,11 @@ class RequestDecoder : public virtual StreamDecoder { | |
| * @return StreamInfo::StreamInfo& the stream_info for this stream. | ||
| */ | ||
| virtual StreamInfo::StreamInfo& streamInfo() PURE; | ||
|
|
||
| /** | ||
| * @return List of shared pointers to access loggers for this stream. | ||
| */ | ||
| virtual std::list<AccessLog::InstanceSharedPtr> accessLogHandlers() PURE; | ||
|
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. A drive-by comment: |
||
| }; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -192,7 +192,7 @@ class ConnectionManagerImpl : Logger::Loggable<Logger::Id::http>, | |||
| void maybeEndDecode(bool end_stream); | ||||
|
|
||||
| // Http::RequestDecoder | ||||
| void decodeHeaders(RequestHeaderMapPtr&& headers, bool end_stream) override; | ||||
| void decodeHeaders(RequestHeaderMapSharedPtr&& headers, bool end_stream) override; | ||||
|
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. Is this interface change needed? It can take a unique_ptr and store the pointee in a shared_ptr.
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. Agreed that keeping the interface unchanged is preferable. I tried changing the interface back to accept a unique ptr, and leaving the member variable as a shared ptr, but ran into the problem that in ActiveStream::RecreateStream we call decodeHeaders on the request_headers_ member variable: envoy/source/common/http/conn_manager_impl.cc Line 1788 in 3752119
|
||||
| void decodeTrailers(RequestTrailerMapPtr&& trailers) override; | ||||
| StreamInfo::StreamInfo& streamInfo() override { return filter_manager_.streamInfo(); } | ||||
| void sendLocalReply(Code code, absl::string_view body, | ||||
|
|
@@ -201,6 +201,13 @@ class ConnectionManagerImpl : Logger::Loggable<Logger::Id::http>, | |||
| absl::string_view details) override { | ||||
| return filter_manager_.sendLocalReply(code, body, modify_headers, grpc_status, details); | ||||
| } | ||||
| std::list<AccessLog::InstanceSharedPtr> accessLogHandlers() override { | ||||
| return filter_manager_.accessLogHandlers(); | ||||
| } | ||||
| void deferHeadersAndTrailers() { | ||||
| response_encoder_->setDeferredLoggingHeadersAndTrailers(request_headers_, response_headers_, | ||||
| response_trailers_, streamInfo()); | ||||
| } | ||||
|
|
||||
| // ScopeTrackedObject | ||||
| void dumpState(std::ostream& os, int indent_level = 0) const override { | ||||
|
|
@@ -361,12 +368,12 @@ class ConnectionManagerImpl : Logger::Loggable<Logger::Id::http>, | |||
| // both locations, then refer to the FM when doing stream logs. | ||||
| const uint64_t stream_id_; | ||||
|
|
||||
| RequestHeaderMapPtr request_headers_; | ||||
| RequestHeaderMapSharedPtr request_headers_; | ||||
| RequestTrailerMapPtr request_trailers_; | ||||
|
|
||||
| ResponseHeaderMapPtr informational_headers_; | ||||
| ResponseHeaderMapPtr response_headers_; | ||||
| ResponseTrailerMapPtr response_trailers_; | ||||
| ResponseHeaderMapSharedPtr response_headers_; | ||||
| ResponseTrailerMapSharedPtr response_trailers_; | ||||
|
|
||||
| // Note: The FM must outlive the above headers, as they are possibly accessed during filter | ||||
| // destruction. | ||||
|
|
||||
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.
You probably already discussed this, but FWIW, I find this dance a bit odd. It's a bit confusing how the headers are passed back and forth now. Perhaps more comments? Also, if this is for logging, can we use a shared_ptr to const object here to make it more clear that these things are not modified after this point?
I do wonder if it would have been easier to understand to keep the deferred logging system inside the HCM (some kind of deferred logging manager) somehow triggered by a codec callback later, but that would be a bigger change so probably not worth it.
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.
Done.
I'll take a pass at more thorough comments/docstrings. Is there anything specifically/particularly confusing that I should clear up?
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.
I've added a few more comments on the methods that pass headers through to the codec.