Replace ':' with '_' in stats name.#1806
Conversation
Signed-off-by: Henna Huang <henna@google.com>
| "#/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.
Are there any non-zero stats that I can check here?
There was a problem hiding this comment.
Can't you check any cluster stat that is per-cluster, adding a : in there?
There was a problem hiding this comment.
These are the cluster stats that I see: https://github.com/envoyproxy/envoy/blob/master/include/envoy/upstream/upstream.h#L177
| *(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.
Probably a good idea to document the s/:/_/ that happens in cluster stats output.
| 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.
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.
@junr03 I've updated to push the character replacement in ScopeImpl. I believe this should work for you also.
Signed-off-by: Henna Huang <henna@google.com>
Signed-off-by: Henna Huang <henna@google.com>
| 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.
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.
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:
|
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <htuch@google.com>
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <htuch@google.com>
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <htuch@google.com>
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 henna@google.com