Skip to content

Commit

Permalink
fix: prom init (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
QizhengMo authored Jan 9, 2024
1 parent bdfa9ec commit 7961ca8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.arextest.web.api.service;

import com.arextest.common.metrics.PrometheusConfiguration;
import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.EnableAsync;

@Slf4j
@EnableAsync
// @EnableSchedulerLock(defaultLockAtMostFor = "PT30S")
@SpringBootApplication(scanBasePackages = "com.arextest.web")
public class WebSpringBootServletInitializer extends SpringBootServletInitializer {
public class WebSpringBootServletInitializer
extends SpringBootServletInitializer
implements ApplicationListener<ApplicationReadyEvent> {

@Value("${arex.prometheus.port}")
String prometheusPort;
Expand All @@ -28,8 +31,8 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder applicatio
return application.sources(WebSpringBootServletInitializer.class);
}

@PostConstruct
public void init() {
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
PrometheusConfiguration.initMetrics(prometheusPort);
}
}

0 comments on commit 7961ca8

Please sign in to comment.