-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Replace ':' with '_' in stats name. #1806
Replace ':' with '_' in stats name. #1806
Conversation
Signed-off-by: Henna Huang <[email protected]>
"#/properties/name\n Schema violation: pattern\n Offending document " | ||
"key: #/name"); | ||
create(parseBootstrapFromJson(json)); | ||
EXPECT_EQ(0, factory_.stats_.counter("cluster.cluster_name.lb_local_cluster_not_ok").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.
Are there any non-zero stats that I can check here?
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't you check any cluster stat that is per-cluster, adding a :
in there?
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.
These are the cluster stats that I see: https://github.com/envoyproxy/envoy/blob/master/include/envoy/upstream/upstream.h#L177
Signed-off-by: Henna Huang <[email protected]>
@@ -31,7 +31,7 @@ Cluster | |||
name | |||
*(required, string)* Supplies the name of the cluster which must be unique across all clusters. | |||
The cluster name is used when emitting :ref:`statistics <config_cluster_manager_cluster_stats>`. | |||
The cluster name can be at most 60 characters long, and must **not** contain ``:``. | |||
The cluster name can be at most 60 characters long. |
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.
Probably a good idea to document the s/:/_/ that happens in cluster stats output.
@@ -81,7 +87,7 @@ ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::Cluster& config, | |||
std::chrono::milliseconds(PROTOBUF_GET_MS_REQUIRED(config, connect_timeout))), | |||
per_connection_buffer_limit_bytes_( | |||
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, per_connection_buffer_limit_bytes, 1024 * 1024)), | |||
stats_scope_(stats.createScope(fmt::format("cluster.{}.", name_))), | |||
stats_scope_(stats.createScope(clusterStatsName(name_))), |
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.
Thoughts on just moving the replace into the implementation of createScope() ? This would cover LDS also and any future cases. @junr03 you should create a scope for RDS stats so that if route table name has ':' in it it would also be fixed. I realize that RDS/LDS also have potential length issues but that is orthogonal to this.
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.
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.
@junr03 I've updated to push the character replacement in ScopeImpl. I believe this should work for you also.
Signed-off-by: Henna Huang <[email protected]>
Signed-off-by: Henna Huang <[email protected]>
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.
LGTM. This is all very-statsd specific, I hope we don't run into situations with other stats sinks which have their own formatting constraints; @mrice32.
std::replace(final_stat_name.begin(), final_stat_name.end(), ':', '_'); | ||
listener_scope_ = parent_.server_.stats().createScope(final_stat_name); | ||
listener_scope_ = | ||
parent_.server_.stats().createScope(fmt::format("listener.{}.", address_->asString())); |
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: may also want to validate this in a unit test.
~ScopeImpl(); | ||
// ':' is a reserved char in statsd. Do the translation here and in | ||
// IsolatedStoreImpl::ScopeImpl. | ||
std::string sanitizeStatsName(const std::string& name) { |
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 we move this into a common utility function.
@htuch I think we have a few choices when it comes to future sinks having similar formatting constraints:
|
Signed-off-by: Henna Huang <[email protected]>
Signed-off-by: Henna Huang <[email protected]>
Signed-off-by: Henna Huang <[email protected]>
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <[email protected]>
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <[email protected]>
Signed-off-by: Mike Schore <[email protected]> Signed-off-by: JP Simard <[email protected]>
Signed-off-by: Mike Schore <[email protected]> Signed-off-by: JP Simard <[email protected]>
Do a character replacement (':' to '_') in ScopeImpl to remove ':' restriction in user defined names. Stats must be created in a dedicated scope.
This PR handles cases that can be resolved by removing invalid character during stats scope creation (ex: cluster name and listener addresses). This PR is not general enough to allow arbitrary naming of counters, gauges, and histograms. The PR also does not reconcile accessing stats using unsanitized stats name.
Fixes #1782
Signed-off-by: Henna Huang [email protected]