Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Improve performance of getOperationName (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu authored May 2, 2022
1 parent 18fab47 commit 8097a51
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ private String getOperationName(Method method) {
} else if (classTraced != null && classTraced.operationName().length() > 0) {
return classTraced.operationName();
}
return String.format("%s.%s", method.getDeclaringClass().getName(), method.getName());

// use a StringBuilder with predefined capacity to compute the operation name for performance reason
String className = method.getDeclaringClass().getName();
String methodName = method.getName();
int capacity = className.length() + methodName.length() + 1;
StringBuilder builder = new StringBuilder(capacity);
builder.append(className).append('.').append(methodName);
return builder.toString();
}

private void logException(Span span, Exception e) {
Expand Down

0 comments on commit 8097a51

Please sign in to comment.