[BAEL-17473] - Moved articles to corrrect places, formatted pom.xmls and added description in readme files
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
## Spring Boot Runtime
|
||||
|
||||
This module contains articles about administering a Spring Boot runtime
|
||||
|
||||
### Relevant Articles:
|
||||
- [Shutdown a Spring Boot Application](https://www.baeldung.com/spring-boot-shutdown)
|
||||
- [Comparing Embedded Servlet Containers in Spring Boot](https://www.baeldung.com/spring-boot-servlet-containers)
|
||||
- [Programmatically Restarting a Spring Boot Application](https://www.baeldung.com/java-restart-spring-boot-app)
|
||||
- [Logging HTTP Requests with Spring Boot Actuator HTTP Tracing](https://www.baeldung.com/spring-boot-actuator-http)
|
||||
- [How to Disable Console Logging in Spring Boot](https://www.baeldung.com/spring-boot-disable-console-logging)
|
||||
- [How to Disable Console Logging in Spring Boot](https://www.baeldung.com/spring-boot-disable-console-logging)
|
||||
- [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs)
|
||||
@@ -100,14 +100,14 @@
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/conf.properties</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/conf.properties</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.baeldung.compare;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ComparisonApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ComparisonApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.baeldung.compare;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import io.micrometer.core.instrument.Meter;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Statistic;
|
||||
|
||||
@Component
|
||||
public class StartupEventHandler {
|
||||
|
||||
// logger, constructor
|
||||
private static Logger logger = LoggerFactory.getLogger(StartupEventHandler.class);
|
||||
|
||||
public StartupEventHandler(MeterRegistry registry) {
|
||||
this.meterRegistry = registry;
|
||||
}
|
||||
|
||||
private String[] METRICS = {
|
||||
"jvm.memory.used",
|
||||
"jvm.classes.loaded",
|
||||
"jvm.threads.live"};
|
||||
|
||||
private String METRIC_MSG_FORMAT = "Startup Metric >> {}={}";
|
||||
|
||||
private MeterRegistry meterRegistry;
|
||||
|
||||
@EventListener
|
||||
public void getAndLogStartupMetrics(
|
||||
ApplicationReadyEvent event) {
|
||||
Arrays.asList(METRICS)
|
||||
.forEach(this::getAndLogActuatorMetric);
|
||||
}
|
||||
|
||||
private void getAndLogActuatorMetric(String metric) {
|
||||
Meter meter = meterRegistry.find(metric).meter();
|
||||
Map<Statistic, Double> stats = getSamples(meter);
|
||||
|
||||
logger.info(METRIC_MSG_FORMAT, metric, stats.get(Statistic.VALUE).longValue());
|
||||
}
|
||||
|
||||
private Map<Statistic, Double> getSamples(Meter meter) {
|
||||
Map<Statistic, Double> samples = new LinkedHashMap<>();
|
||||
mergeMeasurements(samples, meter);
|
||||
return samples;
|
||||
}
|
||||
|
||||
private void mergeMeasurements(Map<Statistic, Double> samples, Meter meter) {
|
||||
meter.measure().forEach((measurement) -> samples.merge(measurement.getStatistic(),
|
||||
measurement.getValue(), mergeFunction(measurement.getStatistic())));
|
||||
}
|
||||
|
||||
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {
|
||||
return Statistic.MAX.equals(statistic) ? Double::max : Double::sum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
# server configuration
|
||||
server.port=4010
|
||||
server.address=127.0.0.1
|
||||
|
||||
## Error handling configuration
|
||||
server.error.whitelabel.enabled=true
|
||||
server.error.path=/user-error
|
||||
server.error.include-exception=true
|
||||
server.error.include-stacktrace=always
|
||||
|
||||
## Server connections configuration
|
||||
server.tomcat.max-threads=200
|
||||
server.connection-timeout=5s
|
||||
server.max-http-header-size=8KB
|
||||
server.tomcat.max-swallow-size=2MB
|
||||
server.tomcat.max-http-post-size=2MB
|
||||
|
||||
## Access logs configuration
|
||||
server.tomcat.accesslog.enabled=true
|
||||
server.tomcat.accesslog.directory=logs
|
||||
server.tomcat.accesslog.file-date-format=yyyy-MM-dd
|
||||
server.tomcat.accesslog.prefix=access_log
|
||||
server.tomcat.accesslog.suffix=.log
|
||||
server.tomcat.accesslog.pattern=common
|
||||
server.tomcat.basedir=tomcat
|
||||
|
||||
## Tomcat internal server logs
|
||||
logging.level.org.apache.tomcat=DEBUG
|
||||
logging.level.org.apache.catalina=DEBUG
|
||||
Reference in New Issue
Block a user