Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metrics bug workaround for spring-projects/spring-boot#31150
Co-authored-by: Marco Geweke <marco.geweke@otto.de>
- Loading branch information
1 parent
3e93b18
commit dea9ae1
Showing
5 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...tto/edison/metricsconfiguration/WebMvcMetricsFilterWorkaroundForBugInSpringBoot2_7_0.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.servlet.DispatcherType; | ||
|
||
@Component | ||
public class WebMvcMetricsFilterWorkaroundForBugInSpringBoot2_7_0 { | ||
|
||
@Bean | ||
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters