Copilot commented on code in PR #13278:
URL: https://github.com/apache/trafficserver/pull/13278#discussion_r3416702133
##########
src/proxy/http/remap/PluginDso.cc:
##########
@@ -55,8 +61,42 @@ concat_error(std::string &error, const std::string &msg)
}
}
+// Derive a metric-safe token from a plugin path: the basename without
extension, with any character
+// outside [A-Za-z0-9_-] replaced by '_' (e.g. "/.../header_rewrite.so" ->
"header_rewrite").
+std::string
+plugin_metric_token(std::string_view name)
+{
+ if (auto slash = name.find_last_of('/'); slash != std::string_view::npos) {
+ name.remove_prefix(slash + 1);
+ }
+ if (auto dot = name.find_first_of('.'); dot != std::string_view::npos) {
+ name = name.substr(0, dot);
+ }
Review Comment:
`plugin_metric_token()` strips the plugin name at the *first* '.' in the
basename. This doesn't match the comment about using the basename stem (i.e.,
only removing the extension) and can cause metric-name collisions for plugins
whose basenames contain dots (e.g. `foo.bar.so` -> `foo`). Use the last '.'
instead so only the extension is removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]