Skip to content

Commit 5cc3af7

Browse files
piscesljlujie64
andauthored
[metric] Optimize the createLogicalScope method by adding empty string checks to avoid unnecessary delimiter concatenation. (#1363)
Co-authored-by: lujie64 <[email protected]>
1 parent 45ac152 commit 5cc3af7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fluss-common/src/main/java/com/alibaba/fluss/metrics/groups/AbstractMetricGroup.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,13 @@ String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex
163163

164164
protected String createLogicalScope(CharacterFilter filter, char delimiter) {
165165
final String groupName = getGroupName(filter);
166-
return parent == null
167-
? groupName
168-
: parent.getLogicalScope(filter, delimiter) + delimiter + groupName;
166+
if (parent == null) {
167+
return groupName;
168+
}
169+
if (groupName == null || groupName.isEmpty()) {
170+
return parent.getLogicalScope(filter, delimiter);
171+
}
172+
return parent.getLogicalScope(filter, delimiter) + delimiter + groupName;
169173
}
170174

171175
/** Return the parent of the metric group. */

0 commit comments

Comments
 (0)