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
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Apr 26, 2022
1 parent 18fab47 commit 4f909cb
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ 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
int capacity = method.getDeclaringClass().getName().length() + method.getName().length() + 1;
StringBuilder builder = new StringBuilder(capacity);
builder.append(method.getDeclaringClass().getName()).append('.').append(method.getName());
return builder.toString();
}

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

0 comments on commit 4f909cb

Please sign in to comment.