package de.otto.edison.metricsconfiguration;

import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter;
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

import javax.servlet.DispatcherType;

/* TODO: Remove this when Spring Boot 2.7.1 is there */
@Component
public class WebMvcMetricsFilterWorkaroundForBugInSpringBoot2_7_0 {

    @Bean
    @ConditionalOnMissingBean
    public FilterRegistrationBean<WebMvcMetricsFilter> webMvcMetricsFilter(MetricsProperties properties,
                                                                           MeterRegistry registry, WebMvcTagsProvider tagsProvider) {
        MetricsProperties.Web.Server.ServerRequest request = properties.getWeb().getServer().getRequest();
        WebMvcMetricsFilter filter = new WebMvcMetricsFilter(registry, tagsProvider, request.getMetricName(),
                request.getAutotime());
        FilterRegistrationBean<WebMvcMetricsFilter> registration = new FilterRegistrationBean<>(filter);
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
        registration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC);
        return registration;
    }

}

@@ -411,24 +411,114 @@
 issingBean;%0A
+import org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean;%0A
 import org.s
@@ -569,24 +569,24 @@
 rationBean;%0A
-
 import org.s
@@ -756,16 +756,19 @@
 ype;%0A%0A/*
+%0A  
  TODO: R
@@ -778,16 +778,22 @@
 ve this 
+class 
 when Spr
@@ -815,16 +815,80 @@
 is there
+%0A   https://github.com/spring-projects/spring-boot/issues/31150%0A
  */%0A@Com
@@ -969,24 +969,24 @@
 %0A%0A    @Bean%0A
-
     @Conditi
@@ -994,24 +994,30 @@
 nalOnMissing
+Filter
 Bean%0A    pub

Change condition to ConditionalOnMissingFilterBean