Skip to content

Commit

Permalink
refactor: Migrate to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
kmccarp and TeamModerne committed Jun 28, 2024
1 parent e4a2df0 commit 13f1da2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public J.CompilationUnit visitCompilationUnit(J.CompilationUnit compilationUnit,
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation mi, ExecutionContext ctx) {
if (registerMatcher.matches(mi)) {
Expression timerName = null;
Expression registry = mi.getArguments().get(0);
Expression registry = mi.getArguments().getFirst();

List<String> builder = new ArrayList<>();
List<Expression> parameters = new ArrayList<>();
Expand All @@ -89,11 +89,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation mi, Execution
while (maybeBuilder instanceof J.MethodInvocation) {
J.MethodInvocation builderMethod = (J.MethodInvocation) maybeBuilder;
if (builderMatcher.matches(maybeBuilder)) {
timerName = builderMethod.getArguments().get(0);
timerName = builderMethod.getArguments().getFirst();
}
else if (tagMatcher.matches(maybeBuilder)) {
builder.add("\n.highCardinalityKeyValue(#{any(String)}, #{any(String)})");
parameters.add(builderMethod.getArguments().get(0));
parameters.add(builderMethod.getArguments().getFirst());
parameters.add(builderMethod.getArguments().get(1));
}
else if (tagsIterableMatcher.matches(maybeBuilder)) {
Expand All @@ -112,7 +112,7 @@ else if (tagsMatcher.matches(maybeBuilder)) {
maybeBuilder = ((J.MethodInvocation) maybeBuilder).getSelect();
}
if (timerName != null) {
parameters.add(0, timerName);
parameters.addFirst(timerName);
parameters.add(1, registry);

maybeAddImport("io.micrometer.observation.Observation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
(String name, String help) -> Counter.builder(name).description(help).register(Metrics.globalRegistry)
).build().apply(getCursor(),
method.getCoordinates().replace(),
method.getArguments().get(0),
method.getArguments().getFirst(),
method.getArguments().get(1));

maybeRemoveImport("misk.metrics.v2.Metrics");
Expand Down

0 comments on commit 13f1da2

Please sign in to comment.