Skip to content

Commit

Permalink
Merge pull request #21043 from geoand/mm-lambdas
Browse files Browse the repository at this point in the history
Remove lambdas from runtime code of Micrometer
  • Loading branch information
geoand authored Oct 27, 2021
2 parents 6b1e076 + 01dc826 commit f886204
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public <T> Supplier<T> buildTimer(Supplier<T> f) {
}
}

class MicrometerTimeRecorder implements TimeRecorder {
static class MicrometerTimeRecorder implements TimeRecorder {
Timer timer;

MicrometerTimeRecorder(Timer timer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.micrometer.runtime;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -127,21 +126,23 @@ public void configureRegistries(MicrometerConfig config,
// configured, some measurements may be missed.
Instance<MeterBinder> allBinders = beanManager.createInstance()
.select(MeterBinder.class, Any.Literal.INSTANCE);
allBinders.forEach(x -> x.bindTo(Metrics.globalRegistry));
for (MeterBinder meterBinder : allBinders) {
meterBinder.bindTo(Metrics.globalRegistry);
}

context.addShutdownTask(new Runnable() {
@Override
public void run() {
if (LaunchMode.current() == LaunchMode.DEVELOPMENT) {
// Drop existing meters (recreated on next use)
Collection<Meter> meters = new ArrayList<>(Metrics.globalRegistry.getMeters());
meters.forEach(m -> Metrics.globalRegistry.remove(m));
for (Meter meter : Metrics.globalRegistry.getMeters()) {
Metrics.globalRegistry.remove(meter);
}
}
for (MeterRegistry meterRegistry : Metrics.globalRegistry.getRegistries()) {
meterRegistry.close();
Metrics.removeRegistry(meterRegistry);
}
Collection<MeterRegistry> cleanup = new ArrayList<>(Metrics.globalRegistry.getRegistries());
cleanup.forEach(x -> {
x.close();
Metrics.removeRegistry(x);
});
}
});
}
Expand Down Expand Up @@ -173,7 +174,7 @@ public static Class<?> getClassForName(String classname) {
Class<?> clazz = null;
try {
clazz = Class.forName(classname, false, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException ignored) {
}
log.debugf("getClass: TCCL: %s ## %s : %s", Thread.currentThread().getContextClassLoader(), classname, (clazz != null));
return clazz;
Expand Down

0 comments on commit f886204

Please sign in to comment.