request_id_utils: add new extension system#10429
request_id_utils: add new extension system#10429mattklein123 merged 45 commits intoenvoyproxy:masterfrom
Conversation
…in issue envoyproxy#7624. Signed-off-by: Ross Delinger <rossd@dropbox.com>
Signed-off-by: Ross Delinger <rossd@dropbox.com>
Signed-off-by: Ross Delinger <rossd@dropbox.com>
Signed-off-by: Ross Delinger <rossd@dropbox.com>
Signed-off-by: Ross Delinger <rossd@dropbox.com>
Signed-off-by: Ross Delinger <rossd@dropbox.com>
…utils Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
…utils Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
…utils Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
mattklein123
left a comment
There was a problem hiding this comment.
At a high level this looks good. Flushing out some comments from a first pass. Thank you!
/wait
| // | ||
| // 3. Tracing decision (sampled, forced, etc) is set in 14th byte of the UUID. | ||
|
|
||
| message UUIDConfig { |
There was a problem hiding this comment.
I don't think we need a config for this. Can we just have this be the default class/impl that is loaded if there is no typed_config specified?
There was a problem hiding this comment.
Any recommendation where should I put a documentation about the default behavior in that case? That and increasing amount of shared logic (between default and custom implementations) were main motivations for introduction of this proto package.
There was a problem hiding this comment.
Maybe just move the documentation above the typed_config field to explain what the behavior is if it's not set?
| "Either routeConfigProvider or scopedRouteConfigProvider should be set in " | ||
| "ConnectionManagerImpl."); | ||
|
|
||
| stream_info_.setRequestIDUtils(connection_manager.config_.requestIDUtils()); |
There was a problem hiding this comment.
Why does stream info need the request ID utiltiies? I'm wondering if whatever stat it is being used for can be stored instead?
There was a problem hiding this comment.
Looks like it's used in two cases:
AccessLog::TraceableRequestFilterandConnectionManagerImpl::ActiveStreamto determine if request is traced (usingTracing::HttpTracerUtility)AccessLog::RuntimeFilteruses it for making deterministic logging sampling decision
Given that AccessLog instances are shared across all L4/L5 connection managers, and RequestIDUtils is configured on per-manager basis we need a side channel for passing this information.
I'm worried about preserving derivatives (boolean isTraced and raw sampling number) as they can become out of sync if request id is changed mid-flight. It doesn't look like any existing extensions currently do it though.
There was a problem hiding this comment.
OK fair enough I think that's fine.
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
|
||
| void UUIDUtils::maybePreserveRequestIDInResponse(Http::ResponseHeaderMap& response_headers, | ||
| const Http::RequestHeaderMap& request_headers) { | ||
| if (request_headers.EnvoyForceTrace() && request_headers.RequestId()) { |
There was a problem hiding this comment.
Alternatively check request_headers.EnvoyForceTrace() can be kept outside of this implementation. In that case we add a configuration option in separate pull request to allow always sending request ID header back even without forced tracing. This way we will be able omit "maybe" part of the method and keep if logic outside.
It's generally useful for correlating requests with client-side logs even if tracing itself is disabled for this particular request.
There was a problem hiding this comment.
Agreed that makes sense to me and has been a requested feature before.
| // generation, validation, and associated tracing operations. | ||
| // | ||
| // If not set, Envoy uses the :ref:`default UUID-based behavior <extension_envoy.request_id_utils.uuid>`. | ||
| RequestIDUtils request_id_utils = 36; |
There was a problem hiding this comment.
Playing naming poker, I think something like RequestIdExtension is probably a better message/field name. The "utils" concept is strictly less descriptive.
There was a problem hiding this comment.
Sure, can rename it. What's about relevant classes in code, should I keep them as is?
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
Something is wrong with circleci, why did it take 6 hours to run tests?.. |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks this is super awesome. Just some small comments and I think we can ship!
/wait
| virtual void set(Http::RequestHeaderMap& request_headers) PURE; | ||
|
|
||
| /** | ||
| * Ensure that a request is configured with a request id. Do not override an ID if request has one |
There was a problem hiding this comment.
+1 let's merge set/ensure and just have a boolean param? I think that would be simpler to understand.
| // 2. Request ID is a universally unique identifier (UUID). | ||
| // | ||
| // 3. Tracing decision (sampled, forced, etc) is set in 14th byte of the UUID. | ||
| RequestIDExtension request_id_extension = 36; |
There was a problem hiding this comment.
Can you add a release note about this? Potentially also update https://www.envoyproxy.io/docs/envoy/latest/extending/extending as well as maybe mention this extensibility somewhere in the HTTP/tracing arch docs?
| namespace Envoy { | ||
| namespace Http { | ||
|
|
||
| class UUIDRequestIDExtension : public RequestIDExtension { |
There was a problem hiding this comment.
nit: small comment above that this is the default implementation if none is configured?
|
|
||
| if (!request_headers.RequestId()) { | ||
| Http::RequestIDExtensionSharedPtr rid_extension = stream_info.getRequestIDExtension(); | ||
| if (rid_extension == nullptr) { |
There was a problem hiding this comment.
This can't happen, right? Or can it happen earlier in server load? If so maybe comment? It seems like maybe this should actually be a function call into the extension to check for something and this might be a bug?
|
|
||
| "envoy.filters.udp_listener.udp_proxy": "//source/extensions/filters/udp/udp_proxy:config", | ||
|
|
||
There was a problem hiding this comment.
nit: revert since no file changes.
…utils Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
Thanks awesome work. Can you merge master again which should fix clang-tidy (and also fix any issues that show up as a result of that). /wait |
…utils Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
|
It looks like clang-tidy has either false-positive or unrelated errors, e.g. it complains about using |
|
The throw issue should be fixed. Did you fully merge orgin/master? cc @lizan |
|
OK I guess there is another issue here. cc @lizan We can force merge if there is no real issue to fix. |
Description: Allows for extensions to customize the behavior of Request ID manipulation. This replaces the UUIDUtils class and makes it generic. This makes it possible to customize how request IDs are used for tracing and logging.
Fixes #7624
Risk Level: Medium/High. Default behavior is kept the same but UUIDUtils are abstracted away.
Testing: Add unit tests
Docs Changes: Updated
Release Notes: