diff --git a/src/main/java/org/openrewrite/micrometer/TimerToObservation.java b/src/main/java/org/openrewrite/micrometer/TimerToObservation.java index d30f688..5cc6f91 100644 --- a/src/main/java/org/openrewrite/micrometer/TimerToObservation.java +++ b/src/main/java/org/openrewrite/micrometer/TimerToObservation.java @@ -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 builder = new ArrayList<>(); List parameters = new ArrayList<>(); @@ -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)) { @@ -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"); diff --git a/src/main/java/org/openrewrite/micrometer/misk/MigrateEmptyLabelMiskCounter.java b/src/main/java/org/openrewrite/micrometer/misk/MigrateEmptyLabelMiskCounter.java index 39b9ceb..4ed7495 100644 --- a/src/main/java/org/openrewrite/micrometer/misk/MigrateEmptyLabelMiskCounter.java +++ b/src/main/java/org/openrewrite/micrometer/misk/MigrateEmptyLabelMiskCounter.java @@ -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");