route: add stats prefix for route#21302
Conversation
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
|
opening API only change for discussion |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks generally makes sense to me with some small comments.
/wait
| NonForwardingAction non_forwarding_action = 18; | ||
|
|
||
| // [#not-implemented-hide:] | ||
| // The human readable prefix to use when emitting statistics for this endpoint. |
There was a problem hiding this comment.
Where are the statistics rooted? Can you clarify?
| // This should be set for highly critical | ||
| // endpoints that you wish to get “perfect” statistics on. |
There was a problem hiding this comment.
| // This should be set for highly critical | |
| // endpoints that you wish to get “perfect” statistics on. | |
| // This can be set for highly critical | |
| // endpoints that one wishes to get “perfect” statistics on. |
| // This should be set for highly critical | ||
| // endpoints that you wish to get “perfect” statistics on. | ||
| // | ||
| // This emits statistics documentation at :ref:`virtual cluster statistics <config_http_filters_router_vcluster_stats>`. |
There was a problem hiding this comment.
| // This emits statistics documentation at :ref:`virtual cluster statistics <config_http_filters_router_vcluster_stats>`. | |
| // This emitted statistics are the same as those documented at :ref:`virtual cluster statistics <config_http_filters_router_vcluster_stats>`. |
| // | ||
| // This emits statistics documentation at :ref:`virtual cluster statistics <config_http_filters_router_vcluster_stats>`. | ||
| // | ||
| // .. note:: |
There was a problem hiding this comment.
| // .. note:: | |
| // .. warning:: |
| // every application endpoint. This is both not easily maintainable and as well the | ||
| // statistics output is not free. |
There was a problem hiding this comment.
| // every application endpoint. This is both not easily maintainable and as well the | |
| // statistics output is not free. | |
| // every application endpoint. This is both not easily maintainable and statistics use a non-trivial amount of memory. |
| // We do not recommend setting up a stat prefix for | ||
| // every application endpoint. This is both not easily maintainable and as well the | ||
| // statistics output is not free. | ||
| string stat_prefix = 19; |
There was a problem hiding this comment.
I assume empty means no endpoints stats? If so can you clarify?
There was a problem hiding this comment.
yes. I will clarify
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
mattklein123
left a comment
There was a problem hiding this comment.
LGTM with small comments. Let's just do the implementation in this PR.
/wait
|
|
||
| // [#not-implemented-hide:] | ||
| // The human readable prefix to use when emitting statistics for this endpoint. | ||
| // The statistics are rooted at vhost.<stat_prefix>. |
There was a problem hiding this comment.
Should't it be something like: vhost..<stat_prefix> ?
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
envoy/router/router.h
Outdated
| /** | ||
| * @return PathStatsConfig the config needed to generate path level stats. | ||
| */ | ||
| virtual const absl::optional<PathStatsConfig>& pathStatsConfig() const PURE; |
There was a problem hiding this comment.
Should we use Ptr instead of optional reference here?
source/common/router/config_impl.cc
Outdated
| ? route.route().host_rewrite_path_regex().substitution() | ||
| : ""), | ||
| append_xfh_(route.route().append_x_forwarded_host()), cluster_name_(route.route().cluster()), | ||
| path_stat_name_storage_(route.stat_prefix(), factory_context.scope().symbolTable()), |
There was a problem hiding this comment.
Is there a way to initialize this only if stat prefix is there? Does it really matter?
There was a problem hiding this comment.
@jmarantz can help review this part. I would have to dig back in and relearn how all of this works at this point. I'm not sure if this is the right way or there is a better way.
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
|
@mattklein123 PTAL. Still need to add tests. Want to get your first pass for the implementation. I will have to add this at few more places like timeouts and need to add tests. |
|
This is how stats will come vhost.backend.path.service1stats.upstream_rq_503: 1 |
ggreenway
left a comment
There was a problem hiding this comment.
This is how stats will come
vhost.backend.path.service1stats.upstream_rq_503: 1 vhost.backend.path.service1stats.upstream_rq_5xx: 1 vhost.backend.path.service1stats.upstream_rq_completed: 1 vhost.backend.path.service2stats.upstream_rq_503: 1 vhost.backend.path.service2stats.upstream_rq_5xx: 1 vhost.backend.path.service2stats.upstream_rq_completed: 1
Please add tag-extraction rules for these stats. See source/common/config/well_known_names.cc and add appropriate rules there.
Related: #21397
mattklein123
left a comment
There was a problem hiding this comment.
Looks directionally correct, modulo some comments from a first pass. Please add tests including integration tests. Thank you!
/wait
| google.protobuf.UInt32Value per_request_buffer_limit_bytes = 16; | ||
|
|
||
| // The human readable prefix to use when emitting statistics for this endpoint. | ||
| // The statistics are rooted at vhost.<<virtual host name>.<stat_prefix>. |
There was a problem hiding this comment.
| // The statistics are rooted at vhost.<<virtual host name>.<stat_prefix>. | |
| // The statistics are rooted at vhost.<virtual host name>.<stat_prefix>. |
source/common/router/router.h
Outdated
| Upstream::ClusterInfoConstSharedPtr cluster_; | ||
| std::unique_ptr<Stats::StatNameDynamicStorage> alt_stat_prefix_; | ||
| const VirtualCluster* request_vcluster_; | ||
| const PathStatsConfig* path_stats_config_; |
There was a problem hiding this comment.
I'm not sure it's worth it to keep a member variable for this. I think you can just look it up when you need it in the route.
There was a problem hiding this comment.
It is needed similar to request_vcluster_ because some of the code that increments metrics does not have access to route (not passed in)
envoy/router/context.h
Outdated
| virtual const VirtualClusterStatNames& virtualClusterStatNames() const PURE; | ||
|
|
||
| /** | ||
| * @return a struct containing StatNames for path level stats. |
There was a problem hiding this comment.
Instead of "path" I would call this "route" level stats as they might match on a lot of different things. Change this here and elsewhere.
envoy/router/router.h
Outdated
| /** | ||
| * @return PathStatsConfig the config needed to generate path level stats. | ||
| */ | ||
| virtual const absl::optional<PathStatsConfig>& pathStatsConfig() const PURE; |
source/common/router/config_impl.cc
Outdated
| std::cout << "Setting retry policy...." << route_config.retry_policy().num_retries().value() | ||
| << "\n"; |
source/common/router/config_impl.cc
Outdated
| ? route.route().host_rewrite_path_regex().substitution() | ||
| : ""), | ||
| append_xfh_(route.route().append_x_forwarded_host()), cluster_name_(route.route().cluster()), | ||
| path_stat_name_storage_(route.stat_prefix(), factory_context.scope().symbolTable()), |
There was a problem hiding this comment.
@jmarantz can help review this part. I would have to dig back in and relearn how all of this works at this point. I'm not sure if this is the right way or there is a better way.
|
Sure. I will be OOO rest of the week. I will address comments and add tests later next week. |
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
mattklein123
left a comment
There was a problem hiding this comment.
LGTM with small comment comment, thanks.
/wait
| // | ||
| // We do not recommend setting up a stat prefix for | ||
| // every application endpoint. This is both not easily maintainable and | ||
| // statistics use a non-trivial amount of memory(approximately 1k per route). |
There was a problem hiding this comment.
| // statistics use a non-trivial amount of memory(approximately 1k per route). | |
| // statistics use a non-trivial amount of memory (approximately 1KiB per route). |
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
|
one more merge-main is needed. |
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
83f70eb
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
Commit Message: add stats prefix for route Additional Description: Adds API for stats generation support per route. Risk Level: Low Testing: Docs Changes: Release Notes: Platform Specific Features: API for envoyproxy#3351 Signed-off-by: Rama Chavali <rama.rao@salesforce.com> Signed-off-by: Amila Senadheera <amila.15@cse.mrt.ac.lk>
Commit Message: add stats prefix for route
Additional Description: Adds API for stats generation support per route.
Risk Level: Low
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
API for #3351