Skip to content

Commit

Permalink
Merge pull request #33 from logchange/spring_boot_3_3
Browse files Browse the repository at this point in the history
Spring Boot 3.3 and Java 17 (hofund core still uses java 8)
  • Loading branch information
marwin1991 authored Jun 30, 2024
2 parents 119263b + d33ea3e commit 9338be1
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 185 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ It also served as a key to activate the switch that opens the Bifrost Bridge.

## Compatibility

| Version | SpringBoot Version |
|:---------:|:---------------------------------------:|
| **0.X.0** | from **2.2.0** (including 3.0.0 and up) |
| Version | SpringBoot Version | Java Version |
|:----------------------:|:---------------------------:|:------------------:|
| **2.X.X** | from **3.3.0** | 17 (hofund-core 8) |
| **1.0.X (deprecated)** | from **2.2.0** to **3.2.X** | 8 |

## Requirements

Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/000001-sping-boot-3_3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: Adjust project for Spring Boot 3.3 and Java 17. Hofund-Core still is based on Java 8.
authors:
- name: Peter Zmilczak
nick: marwin1991
url: https://github.com/marwin1991
type: changed #[added/changed/deprecated/removed/fixed/security/other]
merge_requests:
- 33
12 changes: 7 additions & 5 deletions hofund-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@
<parent>
<groupId>dev.logchange.hofund</groupId>
<artifactId>hofund</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>hofund-core</artifactId>
<packaging>jar</packaging>

<description>
TODO
Core hofund classes allowing to publish prometheus metrics
</description>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>${micrometer-io.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public HofundConnection toHofundConnection() {
private StatusFunction testConnection() {
return () -> {
try {
log.debug("Testing http connection to: " + getTarget() + " url: " + getUrl());
log.debug("Testing http connection to: {} url: {}", getTarget(), getUrl());

if (getCheckingStatus() == CheckingStatus.INACTIVE) {
log.debug("Skipping checking connection to: " + getTarget() + " due to inactive status checking");
log.debug("Skipping checking connection to: {} due to inactive status checking", getTarget());
return Status.INACTIVE;
}

Expand All @@ -88,16 +88,16 @@ private StatusFunction testConnection() {

urlConn.connect();
int responseCode = urlConn.getResponseCode();
log.debug("Connection to url: " + getUrl() + " status code: " + responseCode);
log.debug("Connection to url: {} status code: {}", getUrl(), responseCode);

if (responseCode >= 100 && responseCode < 400) {
return Status.UP;
} else {
log.warn("Error testing connection to: " + getUrl() + " finished with status code: " + responseCode);
log.warn("Error testing connection to: {} finished with status code: {}", getUrl(), responseCode);
return Status.DOWN;
}
} catch (IOException e) {
log.warn("Error testing connection to: " + getUrl() + " msg: " + e.getMessage());
log.warn("Error testing connection to: {} msg: {}", getUrl(), e.getMessage());
log.debug("Exception: ", e);
return Status.DOWN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class HofundConnectionMeter implements MeterBinder {

private static final String NAME = "hofund_connection";
private static final String NAME = "hofund.connection";
private static final String DESCRIPTION = "Current status of given connection";

private final HofundInfoProvider infoProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class HofundGitInfoMeter implements MeterBinder {

private static final String NAME = "hofund_git_info";
private static final String NAME = "hofund.git.info";
private static final String DESCRIPTION = "Basic information about application based on git";

private final HofundGitInfoProvider provider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
public class HofundEdgeMeter implements MeterBinder {

private static final String NAME = "hofund_edge";
private static final String NAME = "hofund.edge";
private static final String DESCRIPTION = "Information about hofund edge, value is always 1.0, to check status use hofund_connection";

private final HofundInfoProvider infoProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public class HofundNodeMeter implements MeterBinder {

private static final String NAME = "hofund_node";
private static final String NAME = "hofund.node";
private static final String DESCRIPTION = "Information about hofund nodes, value is always 1.0, to check status use hofund_info";

private final HofundInfoProvider infoProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class HofundInfoMeter implements MeterBinder {

private static final String NAME = "hofund_info";
private static final String NAME = "hofund.info";
private static final String DESCRIPTION = "Basic information about application";

private final HofundInfoProvider provider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class HofundJavaInfoMeter implements MeterBinder {

private static final String NAME = "hofund_java_info";
private static final String NAME = "hofund.java.info";
private static final String DESCRIPTION = "Basic information about java that is running this application";

private final HofundJavaInfo info;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.logchange.hofund.os;

import dev.logchange.hofund.git.HofundGitInfoProvider;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
Expand All @@ -12,7 +11,7 @@

public class HofundOsInfoMeter implements MeterBinder {

private static final String NAME = "hofund_os_info";
private static final String NAME = "hofund.os.info";
private static final String DESCRIPTION = "Basic information about operating system that is running this application";

private final HofundOsInfo info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class HofundWebServerInfo {
private final String version;

public static HofundWebServerInfo create(String name, String version) {
log.info("Server name: " + name + " version: " + version);
log.info("Server name: {} version: {}", name, version);

return HofundWebServerInfo.builder()
.name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class HofundWebServerInfoMeter implements MeterBinder {

private static final String NAME = "hofund_web_server_info";
private static final String NAME = "hofund.webserver.info";
private static final String DESCRIPTION = "Basic information about web server that is running this application";

private final HofundWebServerInfo info;
Expand Down
26 changes: 8 additions & 18 deletions hofund-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>dev.logchange.hofund</groupId>
<artifactId>hofund</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>hofund-spring-boot-autoconfigure</artifactId>
Expand All @@ -19,50 +19,40 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring-boot.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>dev.logchange.hofund</groupId>
<artifactId>hofund-spring</artifactId>
<version>${project.version}</version>
<optional>true</optional> <!-- Optional, because it's defined in -starter module -->
<optional>true</optional>
</dependency>

<!-- https://www.baeldung.com/maven-optional-dependency#what-is-ltoptionalgt -->

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat-embed-core.version}</version>
<optional>true</optional>
<optional>true</optional><!-- https://www.baeldung.com/maven-optional-dependency#what-is-ltoptionalgt -->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>${micrometer-registry-prometheus.version}</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<!-- usunąć -simpleclient jak hofund oraz softnet-parameters-publisher zostanie dostosowany do SpringBoot 3.3 i micrometer-registry-prometheus 1.13.0-->
<!-- https://github.com/micrometer-metrics/micrometer/wiki/1.13-Migration-Guide -->
<!-- https://github.com/logchange/hofund/issues/32 -->
<!-- https://gitlab.corp.softnet.com.pl/softnet/p31/softnet-parameters-publisher/-/issues/2 -->
<artifactId>micrometer-registry-prometheus-simpleclient</artifactId>
<version>${micrometer-registry-prometheus.version}</version>
<artifactId>micrometer-registry-prometheus</artifactId>
<optional>true</optional>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import dev.logchange.hofund.connection.spring.http.HofundBasicHttpConnectionProvider;
import dev.logchange.hofund.info.HofundInfoProvider;
import dev.logchange.hofund.info.springboot.autoconfigure.HofundInfoAutoConfiguration;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand All @@ -21,9 +21,7 @@

@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
//available since spring boot 2.4.0
//@ConditionalOnEnabledMetricsExport(value="prometheus")
@ConditionalOnClass(PrometheusMeterRegistry.class)
@ConditionalOnEnabledMetricsExport(value="prometheus")
@AutoConfigureAfter(HofundInfoAutoConfiguration.class)
public class HofundConnectionAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import dev.logchange.hofund.git.HofundGitInfoMeter;
import dev.logchange.hofund.git.HofundGitInfoProvider;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
//available since spring boot 2.4.0
//@ConditionalOnEnabledMetricsExport(value="prometheus")
@ConditionalOnClass(PrometheusMeterRegistry.class)
@ConditionalOnEnabledMetricsExport(value="prometheus")
@EnableConfigurationProperties(HofundGitInfoProperties.class)
public class HofundGitInfoAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import dev.logchange.hofund.graph.node.HofundNodeMeter;
import dev.logchange.hofund.info.HofundInfoProvider;
import dev.logchange.hofund.info.springboot.autoconfigure.HofundInfoAutoConfiguration;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -19,9 +18,7 @@

@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
//available since spring boot 2.4.0
//@ConditionalOnEnabledMetricsExport(value="prometheus")
@ConditionalOnClass(PrometheusMeterRegistry.class)
@ConditionalOnEnabledMetricsExport(value="prometheus")
@AutoConfigureAfter({HofundInfoAutoConfiguration.class, HofundConnectionAutoConfiguration.class})
public class HofundGraphAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import dev.logchange.hofund.info.HofundInfoMeter;
import dev.logchange.hofund.info.HofundInfoProvider;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
//available since spring boot 2.4.0
//@ConditionalOnEnabledMetricsExport(value="prometheus")
@ConditionalOnClass(PrometheusMeterRegistry.class)
@ConditionalOnEnabledMetricsExport(value="prometheus")
@EnableConfigurationProperties(HofundInfoProperties.class)
public class HofundInfoAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package dev.logchange.hofund.java.springboot.autoconfigure;

import dev.logchange.hofund.java.HofundJavaInfoMeter;
import dev.logchange.hofund.os.HofundOsInfoMeter;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
//available since spring boot 2.4.0
//@ConditionalOnEnabledMetricsExport(value="prometheus")
@ConditionalOnClass(PrometheusMeterRegistry.class)
@ConditionalOnEnabledMetricsExport(value="prometheus")
public class HofundJavaInfoAutoConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package dev.logchange.hofund.os.springboot.autoconfigure;

import dev.logchange.hofund.info.HofundInfoMeter;
import dev.logchange.hofund.info.HofundInfoProvider;
import dev.logchange.hofund.info.springboot.autoconfigure.HofundInfoProperties;
import dev.logchange.hofund.os.HofundOsInfoMeter;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
//available since spring boot 2.4.0
//@ConditionalOnEnabledMetricsExport(value="prometheus")
@ConditionalOnClass(PrometheusMeterRegistry.class)
@ConditionalOnEnabledMetricsExport(value="prometheus")
public class HofundOsInfoAutoConfiguration {

@Bean
Expand Down
Loading

0 comments on commit 9338be1

Please sign in to comment.