add response code details to stream info#6530
add response code details to stream info#6530mattklein123 merged 5 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Elisha Ziskind <eziskind@google.com>
|
@alyssawilk, could you take a look? |
alyssawilk
left a comment
There was a problem hiding this comment.
Awesome, thanks for tackling this!
| /** | ||
| * @param rc_details the response code details string to set for this request. | ||
| */ | ||
| virtual void setResponseCodeDetails(const std::string& rc_details) PURE; |
There was a problem hiding this comment.
How about absl::string_view?
Some of the details I'd like to see in future include things like passing the http_errno_name from the H1 codec, and those come as char*s, so it'd be nice to avoid stringifying and then copying.
There was a problem hiding this comment.
Ok, changed the signature but I left the StreamInfo field as absl::optionalstd::string so there's still going to be a copy. Do you think I should change the field to absl::string_view as well? For that to be safe we'd need to be sure that the actual storage of the string will outlive the StreamInfo object.
| virtual void setResponseFlag(ResponseFlag response_flag) PURE; | ||
|
|
||
| /** | ||
| * @param rc_details the response code details string to set for this request. |
There was a problem hiding this comment.
Maybe some details here about what response code details are?
source/common/router/router.cc
Outdated
| } | ||
|
|
||
| callbacks_->streamInfo().setResponseCodeDetails( | ||
| StreamInfo::ResponseCodeDetails::get().RC_SET_BY_UPSTREAM); |
There was a problem hiding this comment.
I think this PR would be a bit more correct if you also did the work to set the string to nothing in sendLocalReply.
I don't think we have any response filters that pause on encodeHeaders, but if we did it could be the case that while that encoder filter were doing its RPC, it took too long and for example triggered an idle timeout where the HCM would sendLocalReply. Because that could transform, say, a 200 from upstream to a 408 where the details would eventually be "stream timeout" but for today would be "" rather than "response_code_set_by_upstream"
Signed-off-by: Elisha Ziskind <eziskind@google.com>
|
/retest |
|
🔨 rebuilding |
alyssawilk
left a comment
There was a problem hiding this comment.
LGTM modulo one final nit. @junr03 up for doing the cross company pass since I think you have more context?
| /** | ||
| * Constants for the response code details field of StreamInfo. | ||
| * | ||
| * These provide details about the stream state such as whether the |
There was a problem hiding this comment.
One other minor nit - do you think it's worth clarifying what's done now vs what this will do?
These will provide such details, but right now they only do rc_set_by_upstream
I'd be fine with a tracking issue assigned my way for actually setting values in sendLocalReply and referencing the issue here?
There was a problem hiding this comment.
Filed #6542 to track this. I'll add a reference to this in the code.
Signed-off-by: Elisha Ziskind <eziskind@google.com>
|
/retest |
|
🔨 rebuilding |
|
/retest |
|
🔨 rebuilding |
| return response_code_details_; | ||
| } | ||
|
|
||
| void setResponseCodeDetails(absl::string_view rc_details) override { |
There was a problem hiding this comment.
Is it up to the caller on how to enrich this information? Or do you imagine codifying this somehow, i.e a comma delimited list of details?
There was a problem hiding this comment.
My thinking was that this will be just one of the string constants defined in ResponseCodeDetailValues. That currently only has 1 value but that will change soon (#6542). Also, since this is a string, 3rd party extensions can add additional values if it doesn't make sense to add it to OSS envoy. I don't see a need for making this an array (or comma-separated list). @alyssawilk wdyt?
There was a problem hiding this comment.
Just to add another point - I think the idea is that there should be enough distinct strings available to uniquely specify why envoy is returning an error code (more or less one for each time sendLocalReply is called). So a list of strings should not be necessary.
There was a problem hiding this comment.
I'm fine with it as-is.
For single-hop responses we only need one rc-details. It might be useful to have a full trace of what happened somewhere (500-retried, timeout-retries, gave up and sent 500) but I think that's better off via some other trace mechanism where we can put arbitrary information about how much time was spent in each filter etc. etc.
For multi-hop responses while we might want both layers captured in access logs (e.g. layer-2 envoy had timeout, layer-1 envoy proxied response code sent by upstream) I think that the information from prior hops would be transmitted via headers, and could be sent to access logs via logging the proxy-status header. SG?
| * scoped to avoid collisions. | ||
| */ | ||
| struct ResponseCodeDetailValues { | ||
| const std::string RC_SET_BY_UPSTREAM = "response_code_set_by_upstream"; |
There was a problem hiding this comment.
nit: I wonder if we have to prefix RC here given the structs name?
There was a problem hiding this comment.
Removed the RC_ prefix
Right, I know that the access log already has a reference. I am just wondering if you are also going to add functionality to be able to write this new information the stream info has. So for instance in the access log case are you planning on adding it to the formatter: Just wondering how you are planning to surface the additional info we are adding, the access log just being a concrete place where it could happen. |
Thanks for the pointer - I'll add support for logging this field to access_log_formatter.cc |
|
Yep! No need to add in this PR if that wasn't the plan. I think this PR stands on itself functionally. I was just wondering how you were thinking about surfacing this information to the system's observability layer. |
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Sounds good - I'll add this change in a followup PR. |
|
@junr03 can you take another look? Thanks! |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks, looks good with small nit. Looking forward to seeing this info exposed in access logs and eventually optionally in the actual response body if configured to do so.
/wait
| * scoped to avoid collisions. | ||
| */ | ||
| struct ResponseCodeDetailValues { | ||
| const std::string SET_BY_UPSTREAM = "set_by_upstream"; |
There was a problem hiding this comment.
nit: "set_by_upstream" is a bit vague to me in terms of what it means given we have lots of info in stream info. Perhaps "via_upstream" ? Any other ideas? Also nit, SetByUpstream (trying to avoid capitals for new constants).
There was a problem hiding this comment.
"proxied_from_upstream" or "forwarded_from_upstream"? "via_upstream" is fine too and shorter so I'll go with that :)
Signed-off-by: Elisha Ziskind <eziskind@google.com>
) Description: add formatting for the "response code details" string recently added to the StreamInfo (#6530) Risk Level: low Testing: unit tests Docs Changes: updated Release Notes: updated Signed-off-by: Elisha Ziskind <eziskind@google.com>
Description: add a response code field to the StreamInfo object with a helper class to hold well-known constants. For now this just has 1 value which lets access logs tell if the response is coming from the upstream vs from the envoy itself (in the case of a sendLocalReply), but many more values will added in future PRs. Making this a string rather than an enum so that 3rd parties can extend it.
Risk Level: low
Testing: unit tests
Signed-off-by: Elisha Ziskind eziskind@google.com