Skip to content

route: add stats prefix for route#21302

Merged
jmarantz merged 40 commits intoenvoyproxy:mainfrom
ramaraochavali:fix/route_stats
Jun 16, 2022
Merged

route: add stats prefix for route#21302
jmarantz merged 40 commits intoenvoyproxy:mainfrom
ramaraochavali:fix/route_stats

Conversation

@ramaraochavali
Copy link
Copy Markdown
Contributor

@ramaraochavali ramaraochavali commented May 16, 2022

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

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #21302 was opened by ramaraochavali.

see: more, trace.

@ramaraochavali
Copy link
Copy Markdown
Contributor Author

opening API only change for discussion

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the statistics rooted? Can you clarify?

Comment on lines +263 to +264
// This should be set for highly critical
// endpoints that you wish to get “perfect” statistics on.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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>`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// .. note::
// .. warning::

Comment on lines +271 to +272
// every application endpoint. This is both not easily maintainable and as well the
// statistics output is not free.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume empty means no endpoints stats? If so can you clarify?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I will clarify

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
/**
* @return PathStatsConfig the config needed to generate path level stats.
*/
virtual const absl::optional<PathStatsConfig>& pathStatsConfig() const PURE;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use Ptr instead of optional reference here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine.

? 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()),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to initialize this only if stat prefix is there? Does it really matter?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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>
@ramaraochavali
Copy link
Copy Markdown
Contributor Author

@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.

@ramaraochavali
Copy link
Copy Markdown
Contributor Author

ramaraochavali commented May 25, 2022

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

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The statistics are rooted at vhost.<<virtual host name>.<stat_prefix>.
// The statistics are rooted at vhost.<virtual host name>.<stat_prefix>.

Upstream::ClusterInfoConstSharedPtr cluster_;
std::unique_ptr<Stats::StatNameDynamicStorage> alt_stat_prefix_;
const VirtualCluster* request_vcluster_;
const PathStatsConfig* path_stats_config_;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is needed similar to request_vcluster_ because some of the code that increments metrics does not have access to route (not passed in)

virtual const VirtualClusterStatNames& virtualClusterStatNames() const PURE;

/**
* @return a struct containing StatNames for path level stats.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

/**
* @return PathStatsConfig the config needed to generate path level stats.
*/
virtual const absl::optional<PathStatsConfig>& pathStatsConfig() const PURE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine.

Comment on lines +1093 to +1094
std::cout << "Setting retry policy...." << route_config.retry_policy().num_retries().value()
<< "\n";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

? 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()),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@ramaraochavali
Copy link
Copy Markdown
Contributor Author

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>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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>
jmarantz
jmarantz previously approved these changes Jun 15, 2022
mattklein123
mattklein123 previously approved these changes Jun 15, 2022
@mattklein123 mattklein123 dismissed ggreenway’s stale review June 15, 2022 16:23

comment's addressed

@jmarantz
Copy link
Copy Markdown
Contributor

one more merge-main is needed.

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
jmarantz
jmarantz previously approved these changes Jun 16, 2022
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@ramaraochavali
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #21302 (comment) was created by @ramaraochavali.

see: more, trace.

@ramaraochavali
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #21302 (comment) was created by @ramaraochavali.

see: more, trace.

@jmarantz jmarantz merged commit 7b937e8 into envoyproxy:main Jun 16, 2022
@ramaraochavali ramaraochavali deleted the fix/route_stats branch June 16, 2022 13:21
Amila-Rukshan pushed a commit to Amila-Rukshan/envoy that referenced this pull request Jun 28, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants