Skip to content

Commit

Permalink
Add metrics bug workaround for spring-projects/spring-boot#31150
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Geweke <marco.geweke@otto.de>
  • Loading branch information
MediaMarco committed May 24, 2022
1 parent 3e93b18 commit dea9ae1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Release Notes

## 2.7.0-SNAPSHOT
* **[all]**
* Update to Spring Boot 2.7.0 (With Metrics bug workaround https://github.com/spring-projects/spring-boot/issues/31150)
* Update to UnboundID LDAP SDK for Java 6.0.5 which was outdated since the minimal variant was aborted 2017

## 2.6.10
* **[edison-jobs]**
* Configure read and write timeout in MongoJobMetaRepository
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -25,7 +25,7 @@ plugins {
// DO NOT FORGET TO DOCUMENT CHANGES IN CHANGELOG.md
//
// Add a GitHub release for every new release: https://github.com/otto-de/edison-microservice/releases
def edison_version = "2.6.10"
def edison_version = "2.7.0-SNAPSHOT"
//
//
//
Expand Down
@@ -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;
}

}
Expand Up @@ -3,7 +3,7 @@
import de.otto.edison.status.indicator.ApplicationStatusAggregator;
import org.springframework.scheduling.annotation.Scheduled;

public class EveryTenSecondsScheduler implements Scheduler{
public class EveryTenSecondsScheduler implements Scheduler {

private static final int TEN_SECONDS = 10 * 1000;

Expand Down
Expand Up @@ -31,7 +31,6 @@
import static de.otto.edison.jobs.domain.Level.INFO;
import static de.otto.edison.jobs.domain.Level.WARNING;
import static de.otto.edison.jobs.service.JobRunner.newJobRunner;
import static java.lang.String.format;
import static java.lang.System.currentTimeMillis;
import static java.time.OffsetDateTime.now;
import static java.util.Collections.emptyList;
Expand Down Expand Up @@ -150,7 +149,7 @@ public void killJobsDeadSince(final int seconds) {

/**
* Checks all run locks and releases the lock, if the job is stopped.
*
* <p>
* TODO: This method should never do something, otherwise the is a bug in the lock handling.
* TODO: Check Log files + Remove
*/
Expand All @@ -160,7 +159,7 @@ private void clearRunLocks() {
if (jobInfoOptional.isPresent() && jobInfoOptional.get().isStopped()) {
jobMetaService.releaseRunLock(runningJob.jobType);
LOG.error("Clear Lock of Job {}. Job stopped already.", runningJob.jobType);
} else if (!jobInfoOptional.isPresent()){
} else if (!jobInfoOptional.isPresent()) {
jobMetaService.releaseRunLock(runningJob.jobType);
LOG.error("Clear Lock of Job {}. JobID does not exist", runningJob.jobType);
}
Expand Down

0 comments on commit dea9ae1

Please sign in to comment.