You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] AccessLogFilter for path matrics make Server OOM #2566
To fix the OOM issue caused by variable paths in metrics collection in the AccessLogFilter class, you can normalize the paths to avoid creating too many unique metric names. One common approach is to replace variable parts of the path (like IDs) with placeholders.
Here's the modified AccessLogFilter class with the fix:
In this code, the normalizePath method replaces numeric IDs and UUIDs in the path with placeholders, which helps to reduce the number of unique metric names and prevent the OOM issue [1].
private String normalizePath(String path) {
// Replace variable parts of the path with placeholders
return path.replaceAll("/\\d+", "/{id}")
.replaceAll("/[a-f0-9-]{36}", "/{uuid}");
}
To handle paths with variable parts such as /graphs/hugegraph/graph/vertices/"2:mako", you can modify the normalizePath method to replace variable parts with placeholders. This will help in normalizing the paths for consistent logging and metrics collection.
Here is an example of how you can modify the normalizePath method:
privatestaticfinalStringVARIABLE_PART_REGEX = "/\\d+:\\w+";
privateStringnormalizePath(Stringpath) {
// Replace variable parts with a placeholderreturnpath.replaceAll(VARIABLE_PART_REGEX, "/{variable}")
.replaceAll("/\\d+", "/{id}")
.replaceAll("/[a-f0-9-]{36}", "/{uuid}");
}
You can then use this normalizePath method in the filter method to normalize the path before using it for metrics and logging:
Activity
JackyYangPassion commentedon Jul 1, 2024
@dosu can you help me fix this bug
JackyYangPassion commentedon Jul 1, 2024
Bug releated PR #2286
JackyYangPassion commentedon Jul 2, 2024
The root casue is this class logic
AccessLogFilter.java
@dosu could you fix this bug
dosubot commentedon Jul 2, 2024
To fix the OOM issue caused by variable paths in metrics collection in the
AccessLogFilterclass, you can normalize the paths to avoid creating too many unique metric names. One common approach is to replace variable parts of the path (like IDs) with placeholders.Here's the modified
AccessLogFilterclass with the fix:In this code, the
normalizePathmethod replaces numeric IDs and UUIDs in the path with placeholders, which helps to reduce the number of unique metric names and prevent the OOM issue [1].To continue talking to Dosu, mention @dosu.
JackyYangPassion commentedon Jul 2, 2024
@dosu 上边思路是正确的,但是
方法不能覆盖path = /graphs/hugegraph/graph/vertices/"2:mako" 这种场景,请修正下代码
dosubot commentedon Jul 2, 2024
To handle paths with variable parts such as
/graphs/hugegraph/graph/vertices/"2:mako", you can modify thenormalizePathmethod to replace variable parts with placeholders. This will help in normalizing the paths for consistent logging and metrics collection.Here is an example of how you can modify the
normalizePathmethod:You can then use this
normalizePathmethod in thefiltermethod to normalize the path before using it for metrics and logging:This modification ensures that paths with variable parts are normalized, making the logging and metrics collection more consistent [1].
To continue talking to Dosu, mention @dosu.
JackyYangPassion commentedon Jul 2, 2024
fix #2569