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
tracing: enhance custom tags source #8279
tracing: enhance custom tags source #8279
Conversation
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.
From a quick look, it seems like a good start. Couple of general points:
- Could you rename the field from
additional_tags
tocustom_tags
- so the name of the field and type is consistent. - Sampling config can now also be set at the route level - not necessarily for this PR, but might also be good to consider whether we want these custom tags to also be configurable at that level. If so - we need to decide how the route level custom tags are handled - probably override/merge based on whether common tag names are used.
@objectiser thanks.
Fixed.
I'll have a look. |
@snowp can you have a look? |
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.
Thanks this looks reasonable to me.
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
source/extensions/filters/network/http_connection_manager/config.cc
Outdated
Show resolved
Hide resolved
ping @snowp , would you have another look please? |
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.
Thanks for iterating on this! Definitely moving in the right direction
source/extensions/filters/network/http_connection_manager/config.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/network/http_connection_manager/config.cc
Outdated
Show resolved
Hide resolved
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.
Thanks for working on this. Flushing out some API level comments. Let's nail that first and then we can move on to code review. Also please merge mater to pick up the new formatter tooling.
/wait
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
thanks @mattklein123 , maybe we should new a PR for the API(protos) change first, then do the implementation? |
I think it's fine to do it in this PR, but let's lock down the API first even if CI is not passing. /wait |
Should we also expose ability to set tags from dynamic metadata from the node, route, or route entry? |
@kyessenov @mandarjog I think you are describing the same point, both for some kind of dynamic metadata? |
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.
Looking good - thanks for all the hard work on this!
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
api/envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
api/envoy/type/tracing.proto
Outdated
// environment variable name to obtain the value to populate the tag value. | ||
string name = 1 [(validate.rules).string = {min_bytes: 1}]; | ||
|
||
// used to populate the tag value is the environment variable is not found. |
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.
"value if the ..."
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.
fixed
api/envoy/type/tracing.proto
Outdated
} | ||
|
||
// RouteMetadata type custom tag with namespace, path, and default value. | ||
message RouteMetadata { |
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 seems like an exact copy of the RequestMetadata
- would be better to just have message Metadata
and use for both request_metadata
and route_metadata
fields below.
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.
unified
api/envoy/type/tracing.proto
Outdated
string default_value = 4; | ||
} | ||
|
||
reserved 2, 3; |
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.
Why are these reserved when this is a new proto message?
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.
fixed.
EnvironmentCustomTag::EnvironmentCustomTag(const std::string& tag, const std::string& name, | ||
const std::string& default_value) | ||
: DynamicCustomTag(tag, default_value), name_(name) {} | ||
absl::string_view EnvironmentCustomTag::obtainValue(const CustomTagContext&) const { |
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.
nit: line above
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.
outdated
const std::string& default_value) | ||
: DynamicCustomTag(tag, default_value), name_(name) {} | ||
absl::string_view EnvironmentCustomTag::obtainValue(const CustomTagContext&) const { | ||
return std::getenv(name_.data()); |
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.
Might want to only call this on initialisation, rather than per request - to avoid unnecessary system call. This was raised as a point on the istio P&T call when discussing this feature - to ensure it is as efficient as possible.
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.
fixed.
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.
Thanks, looking good. Flushing out some high level API/interface comments.
/wait
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
api/envoy/config/filter/network/http_connection_manager/v3alpha/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
api/envoy/type/tracing.proto
Outdated
// environment variable name to obtain the value to populate the tag value. | ||
string name = 1 [(validate.rules).string = {min_bytes: 1}]; | ||
|
||
// used to populate the tag value if the environment variable is not found. |
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.
Should this be required? If not, what is the behavior if this is empty? Does the tag get populated with an empty value? Not populated? Please document.
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.
commented
api/envoy/type/tracing.proto
Outdated
// request header name to obtain the value to populate the tag value. | ||
string name = 1 [(validate.rules).string = {min_bytes: 1}]; | ||
|
||
// used to populate the tag value if the name is not found in request header map. |
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.
Same comment here as above.
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.
commented
api/envoy/type/tracing.proto
Outdated
message TracingCustomTag { | ||
// Literal type custom tag with literal value for tag value. | ||
message Literal { | ||
// literal value to populate the tag value. |
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.
nit: Please use proper grammar for all doc comments including starting sentence with a capital letter. Same elsewhere.
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.
fixed.
api/envoy/type/tracing.proto
Outdated
// specify the separator for the full path. | ||
string path_separator = 3; | ||
|
||
// used to populate the tag value if no metadata found. |
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.
Same comment here as above.
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.
commented
api/envoy/type/tracing.proto
Outdated
string default_value = 2; | ||
} | ||
|
||
// Metadata type custom tag with namespace, path, and default value. |
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.
Can you flesh out the docs for this including potentially a full YAML example? It's confusing to me with these docs to understand how this actually works, what path is, path_separator, etc.
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.
documented.
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.
Thanks looks good. Few more comments.
/wait
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Show resolved
Hide resolved
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.
@envoyproxy/api-shepherds API LGTM
Signed-off-by: Yi Tang <ssnailtang@gmail.com>
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.
Thanks, LGTM with 2 small comments.
/wait
@@ -33,6 +33,14 @@ parseHttpConnectionManagerFromV2Yaml(const std::string& yaml) { | |||
return http_connection_manager; | |||
} | |||
|
|||
envoy::config::filter::network::http_connection_manager::v2::HttpConnectionManager | |||
parseHttpConnectionManagerFromV2YamlAndValidate(const std::string& yaml) { |
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.
Sorry I meant for you to just change the previous parseHttpConnectionManagerFromV2Yaml
to always validate vs. add a new function. Can you do that?
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.
No, I can't, or it should be done in another PR, some other case will fail by validating
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.
OK no problem, let's do this in a follow up please. Can you add a TODO?
@@ -1346,15 +1346,15 @@ void ConnectionManagerImpl::ActiveStream::refreshCachedTracingCustomTags() { | |||
if (!connection_manager_.config_.tracingConfig()) { | |||
return; | |||
} | |||
Tracing::CustomTagMap& customTagMap = getOrMakeTracingCustomTagMap(); | |||
Tracing::CustomTagMap& custom_tag_map = getOrMakeTracingCustomTagMap(); |
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.
In many cases there will be no custom tags. Can we avoid creating the map until we know there are custom tags on the route or HCM level below?
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.
Ok I did like it before IIRC :), I'll add it back.
PS, checking the tracing config before all even though there are custom tags on the route level is needed, the tracing will be processed only when tracing in HCM configured.
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.
Fixed
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.
Awesome work. 2 small comments and let's ship!
/wait
if (hasCachedRoute() && cached_route_.value()->tracingConfig()) { | ||
route_tags = &cached_route_.value()->tracingConfig()->getCustomTags(); | ||
} | ||
bool configured_in_conn = !conn_manager_tags.empty(); |
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.
nit: const here and next line
@@ -33,6 +33,14 @@ parseHttpConnectionManagerFromV2Yaml(const std::string& yaml) { | |||
return http_connection_manager; | |||
} | |||
|
|||
envoy::config::filter::network::http_connection_manager::v2::HttpConnectionManager | |||
parseHttpConnectionManagerFromV2YamlAndValidate(const std::string& yaml) { |
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.
OK no problem, let's do this in a follow up please. Can you add a TODO?
Signed-off-by: Yi Tang <ssnailtang@gmail.com>
/retest |
🙀 Error while processing event:
|
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.
Thanks!
Thank you all for your help in the long way, :) . |
Great job @yittg ! |
Signed-off-by: Yi Tang ssnailtang@gmail.com
Description:
Deprecated:
request_headers_for_tags
field in HTTP connection manager has been deprecated in favor of thecustom_tags
field.Risk Level: Medium
Testing: unit test
Docs Changes: proto docs
Fixes #8224