Skip to content

Commit

Permalink
Add custom actuator info endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ties committed Oct 10, 2023
1 parent 17669be commit c2da3f1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/java/net/ripe/rpki/rsyncit/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
import jakarta.annotation.PostConstruct;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.boot.info.GitProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.time.Duration;
import java.util.Map;
import java.util.function.Function;

@Component
@Getter
public class AppConfig {
public class AppConfig implements InfoContributor {

private final String rrdpUrl;
private final String rrdpReplaceHostWith;
Expand Down Expand Up @@ -50,6 +53,7 @@ public AppConfig(@Value("${rrdpUrl}") String rrdpUrl,
Gauge.builder("rsyncit.configuration", () -> 1.0)
.baseUnit("info")
.tag("rrdp_url", rrdpUrl)
.tag("rrdp_override_host", rrdpReplaceHostWith)
.tag("request_timeout_seconds", String.valueOf(requestTimeout.toSeconds()))
.tag("retention_period_minutes", String.valueOf(Duration.ofMillis(targetDirectoryRetentionPeriodMs).toMinutes()))
.tag("retention_copies", String.valueOf(targetDirectoryRetentionCopiesCount))
Expand Down Expand Up @@ -78,5 +82,17 @@ static Function<String, String> substitutor(String rrdpReplaceHostWith) {
public static ApplicationInfo appInfo(GitProperties gitProperties) {
return new ApplicationInfo(gitProperties.getShortCommitId());
}

@Override
public void contribute(Info.Builder builder) {
builder.withDetail("config", Map.of(
"cron", cron,
"rrdp_url", rrdpUrl,
"rrdp_replace_host", rrdpReplaceHostWith,
"rsync_path", rsyncPath,
"request_timeout_seconds", String.valueOf(requestTimeout.toSeconds()),
"retention_period_minutes", String.valueOf(Duration.ofMillis(targetDirectoryRetentionPeriodMs).toMinutes()),
"retention_copies", String.valueOf(targetDirectoryRetentionCopiesCount),
"build", info.gitCommitId()
));
}
}

0 comments on commit c2da3f1

Please sign in to comment.