Repository: quarkusio/quarkus
Issue: NullPointerException in MicrometerRecorder.registerMetrics

### Describe the bug

Hello Quarkus-Team,

great work. I'm currently moving a project from tomee to quarkus. This is a example project for my students in "database technology". So I have used a lot of your extensions for jpa, mongodb, neo4j, cassandra, ... All worked absolutly fine. In a last step I want to introduce the extension "quarkus-micrometer-registry-prometheus" to demonstrate the use of prometheus as a time series database. When I add this extension, the project doesn't start any more. The exception is:

```
2021-09-23 08:55:32,209 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.lang.NullPointerException
	at io.quarkus.micrometer.runtime.MicrometerRecorder.registerMetrics(MicrometerRecorder.java:169)
	at io.quarkus.deployment.steps.MicrometerProcessor$configureRegistry-2125003310.deploy_0(MicrometerProcessor$configureRegistry-2125003310.zig:123)
	at io.quarkus.deployment.steps.MicrometerProcessor$configureRegistry-2125003310.deploy(MicrometerProcessor$configureRegistry-2125003310.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:1189)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:101)
```

It seems to me, that one of my lot of extension does not work correctly and so corrupt the complete system.

Is it possible, that you do a null check in the registerMetrics method (the parameter consumer is called with null)?

```java
    public void registerMetrics(Consumer<MetricsFactory> consumer) {
        consumer.accept(factory);
    }
```

I do a greater google search but it seems that no other people has my problem ;-)

I have tried to deactivate all of the metrics in the application.properties to find the "corrupt" extension but no of these deactivations have an effect to my NullPointerProblem. 

```
quarkus.micrometer.binder.jvm=false
quarkus.micrometer.binder.system=false
quarkus.micrometer.binder-enabled-default=false
quarkus.micrometer.registry-enabled-default=false
quarkus.scheduler.metrics.enabled=false
quarkus.datasource.jdbc.enable-metrics=false
quarkus.datasource.metrics.enabled=false
quarkus.hibernate-orm.statistics=false
quarkus.hibernate-orm.metrics.enabled=false
quarkus.neo4j.pool.metrics.enabled=false
quarkus.log.metrics.enabled=false
quarkus.smallrye-graphql.metrics.enabled=false
quarkus.grpc.metrics.enabled=false
```

Only when I deactivate all with "quarkus.micrometer.enabled=true" there is no NullPointerException any more. But then I also have no metrics ;-)

For me, this is not a serious problem, because that is a project for students, but I want to report the problem so that you can think about a null check at this point.

Bye 
Rolf


### Expected behavior

_No response_

### Actual behavior

_No response_

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.1.0.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java

diff --git a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java
index cc01bcb212c..8e058dcfc9d 100644
--- a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java
+++ b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java
@@ -235,7 +235,7 @@ void registerExtensionMetrics(MicrometerRecorder recorder,
         // RootMeterRegistryBuildItem is present to indicate we call this after the root registry has been initialized
 
         for (MetricsFactoryConsumerBuildItem item : metricsFactoryConsumerBuildItems) {
-            if (item.executionTime() == ExecutionTime.STATIC_INIT) {
+            if (item != null && item.executionTime() == ExecutionTime.STATIC_INIT) {
                 recorder.registerMetrics(item.getConsumer());
             }
         }
@@ -261,7 +261,7 @@ void configureRegistry(MicrometerRecorder recorder,
         recorder.configureRegistries(config, typeClasses, shutdownContextBuildItem);
 
         for (MetricsFactoryConsumerBuildItem item : metricsFactoryConsumerBuildItems) {
-            if (item.executionTime() == ExecutionTime.RUNTIME_INIT) {
+            if (item != null && item.executionTime() == ExecutionTime.RUNTIME_INIT) {
                 recorder.registerMetrics(item.getConsumer());
             }
         }