Java Code Examples for org.springframework.boot.actuate.info.Info#Builder

The following examples show how to use org.springframework.boot.actuate.info.Info#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BomRangesInfoContributor.java    From initializr with Apache License 2.0 6 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
	Map<String, Object> details = new LinkedHashMap<>();
	this.metadataProvider.get().getConfiguration().getEnv().getBoms().forEach((k, v) -> {
		if (v.getMappings() != null && !v.getMappings().isEmpty()) {
			Map<String, Object> bom = new LinkedHashMap<>();
			v.getMappings().forEach((it) -> {
				String requirement = "Spring Boot " + it.determineCompatibilityRangeRequirement();
				bom.put(it.getVersion(), requirement);
			});
			details.put(k, bom);
		}
	});
	if (!details.isEmpty()) {
		builder.withDetail("bom-ranges", details);
	}
}
 
Example 2
Source File: LeaderInfoContributorTest.java    From spring-cloud-kubernetes with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void infoWhenLeader() {
	given(this.mockLeadershipController.getLocalLeader())
			.willReturn(Optional.of(this.mockLeader));
	given(this.mockLeader.isCandidate(this.mockCandidate)).willReturn(true);
	given(this.mockLeader.getRole()).willReturn("testRole");
	given(this.mockLeader.getId()).willReturn("id");
	Info.Builder builder = new Info.Builder();

	leaderInfoContributor.contribute(builder);

	Map<String, Object> details = (Map<String, Object>) builder.build()
			.get("leaderElection");
	assertThat(details).containsEntry("isLeader", true);
	assertThat(details).containsEntry("leaderId", "id");
	assertThat(details).containsEntry("role", "testRole");
}
 
Example 3
Source File: LeaderInfoContributorTest.java    From spring-cloud-kubernetes with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void infoWhenAnotherIsLeader() {
	given(this.mockLeadershipController.getLocalLeader())
			.willReturn(Optional.of(this.mockLeader));
	given(this.mockLeader.getRole()).willReturn("testRole");
	given(this.mockLeader.getId()).willReturn("id");
	Info.Builder builder = new Info.Builder();

	leaderInfoContributor.contribute(builder);

	Map<String, Object> details = (Map<String, Object>) builder.build()
			.get("leaderElection");
	assertThat(details).containsEntry("isLeader", false);
	assertThat(details).containsEntry("leaderId", "id");
	assertThat(details).containsEntry("role", "testRole");
}
 
Example 4
Source File: CamelInfoTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldHaveInfo() throws Exception {
    Info.Builder builder = new Info.Builder();
    indicator.contribute(builder);
    assertNotNull(builder);

    assertEquals(camelContext.getName(), builder.build().get("camel.name"));
    assertEquals(camelContext.getVersion(), builder.build().get("camel.version"));
}
 
Example 5
Source File: CamelInfoContributor.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    if (camelContext != null) {
        builder.withDetail("camel.name", camelContext.getName());
        builder.withDetail("camel.version", camelContext.getVersion());
        if (camelContext.getUptime() != null) {
            builder.withDetail("camel.uptime", camelContext.getUptime());
            builder.withDetail("camel.uptimeMillis", camelContext.getUptimeMillis());
        }
        builder.withDetail("camel.status", camelContext.getStatus().name());
    }
}
 
Example 6
Source File: ClockInfoContributor.java    From kid-bank with Apache License 2.0 5 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
  ImmutableMap<Object, Object> infoMap = ImmutableMap.of(
      "ZoneID", clock.getZone(),
      "Date/Time", clock.instant()
  );
  builder.withDetail("Clock Info", infoMap);
}
 
Example 7
Source File: DependencyRangesInfoContributor.java    From initializr with Apache License 2.0 5 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
	Map<String, Object> details = new LinkedHashMap<>();
	this.metadataProvider.get().getDependencies().getAll().forEach((dependency) -> {
		if (dependency.getBom() == null) {
			contribute(details, dependency);
		}
	});
	if (!details.isEmpty()) {
		builder.withDetail("dependency-ranges", details);
	}
}
 
Example 8
Source File: LeaderInfoContributorTest.java    From spring-cloud-kubernetes with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void infoWithoutLeader() {
	Info.Builder builder = new Info.Builder();

	leaderInfoContributor.contribute(builder);

	Map<String, Object> details = (Map<String, Object>) builder.build()
			.get("leaderElection");
	assertThat(details).containsEntry("leaderId", "Unknown");
}
 
Example 9
Source File: CustomInfoContributor.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    String hostname;
    try {
        hostname = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        log.warn("Problem trying to resolve the hostname", e);
        hostname = "UNKNOWN";
    }
    builder.withDetail("hostname", hostname);
}
 
Example 10
Source File: TotalUsersInfoContributor.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    Map<String, Integer> userDetails = new HashMap<>();
    userDetails.put("active", userRepository.countByStatus(1));
    userDetails.put("inactive", userRepository.countByStatus(0));

    builder.withDetail("users", userDetails);
}
 
Example 11
Source File: BomRangesInfoContributorTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private static Info getInfo(InitializrMetadata metadata) {
	Info.Builder builder = new Info.Builder();
	new BomRangesInfoContributor(new SimpleInitializrMetadataProvider(metadata)).contribute(builder);
	return builder.build();
}
 
Example 12
Source File: DependencyRangesInfoContributorTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private static Info getInfo(InitializrMetadata metadata) {
	Info.Builder builder = new Info.Builder();
	new DependencyRangesInfoContributor(new SimpleInitializrMetadataProvider(metadata)).contribute(builder);
	return builder.build();
}
 
Example 13
Source File: VersionController.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    builder.withDetail("version", version);
}
 
Example 14
Source File: ActiveProfilesInfoContributor.java    From jhipster with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void contribute(Info.Builder builder) {
    builder.withDetail(ACTIVE_PROFILES, this.profiles);
}
 
Example 15
Source File: FlowableInfoContributor.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    builder.withDetail("flowable", version());
}
 
Example 16
Source File: InstanceInfoContributor.java    From github-analytics with Apache License 2.0 4 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    builder.withDetail("cf_instance",
            Collections.singletonMap("id", System.getenv("INSTANCE_GUID")));
}
 
Example 17
Source File: CustomInformationInfo.java    From heimdall with Apache License 2.0 4 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    builder.withDetail("traces", !property.getTrace().isPrintAllTrace() && property.getMongo().getEnabled());
    builder.withDetail("analytics", property.getMongo().getEnabled());
}
 
Example 18
Source File: StatisticsContributor.java    From steady with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void contribute(Info.Builder builder) {
    Map<String, Integer> vulasStats = new HashMap<String, Integer>();
    //number of vulnerable dependencies with affected true or null ('!' and '?')
   // vulasStats.put("vulnDeps_count", appVulDepRepository.countVulnDeps());
    //number of vulnerable dependencies with affected true ('!')
   //  vulasStats.put("confirmed_vulnDeps_count", appVulDepRepository.countConfirmedVulnDeps());
     
    //number of vulndeps (! ) , NOT in scope test or provided for latest g,a,v
    vulasStats.put("confirmed_vulnDeps_for_latest_versions_count", appVulDepRepository.countConfirmedVulnDepsLatestRuns()); 
     
    //number of vulndeps (! and ?) for latest g,a,v
   // vulasStats.put("vulnDeps_for_latest_versions_count", appVulDepRepository.countVulnDepsLatestRuns());
    
    //number of groups
    vulasStats.put("groups_count", appVulDepRepository.countGroups());
    //number of groups with at least one vulndeps '!' , NOT in scope test or provided 
    vulasStats.put("vulnerable_groups_count", appVulDepRepository.countConfirmedVulnerableLatestGroup());  
    //number of groups with at least one vulndeps '!' or '?'
//    vulasStats.put("vulnerable_groups_count", appVulDepRepository.countVulnerableGroups());
    
    //number of g,a
  //  vulasStats.put("group_artifacts_count", appVulDepRepository.countGroupArtifacts());
    
    //number of LATEST g,a
    vulasStats.put("latest_group_artifacts_count", appVulDepRepository.countLatestGroupArtifacts());
    //number of g,a with at least one vulndeps '!' or '?'
 //   vulasStats.put("vulnerable_group_artifacts_count", appVulDepRepository.countVulnerableGroupArtifacts());
    //number of LATEST g,a with at least one vulndeps (!) NOT in scope test or provided
    vulasStats.put("vulnerable_latest_group_artifacts_count", appVulDepRepository.countConfirmedVulnerableLatestGroupArtifacts());
    //number of LATEST g,a with at least one vulndeps (! and ?)
    //vulasStats.put("vulnerable_latest_group_artifacts_count", appVulDepRepository.countVulnerableLatestGroupArtifacts());
    
    //number of gav
    //vulasStats.put("group_artifact_versions_count", appVulDepRepository.countGAVs());
    //number of LATEST gav. only considering the latest this is equal to countLatestGroupArtifacts()
//    vulasStats.put("group_artifact_versions_count", appVulDepRepository.countLatestGAVs());
    //number of gav with at least one vulndeps '!' or '?'
 //   vulasStats.put("vulnerable_group_artifact_versions_count", appVulDepRepository.countVulnerableGAVs());
    //number of gav with at least one vulndeps '!' 
    //only considering the latest version, this returns exactly the same then countConfirmedVulnerableLatestGroupArtifacts()
//    vulasStats.put("vulnerable_latest_group_artifact_versions_count", appVulDepRepository.countConfirmedLatestVulnerableGAVs());
    //number of bugs
    vulasStats.put("bugs_count", appVulDepRepository.countBugs());

    
 
  builder.withDetail("stats", vulasStats);
 
  Map<String, ArrayList<String>> execStats = new HashMap<String, ArrayList<String>>();
  execStats.put("exe", appVulDepRepository.getGoalExecutions());
  builder.withDetail("execStats", execStats);
  
  Map<String, ArrayList<String>> gaStats = new HashMap<String, ArrayList<String>>();
  gaStats.put("group_artifact_vulndepCount", appVulDepRepository.getVulnDepsLatestGroupArtifacts());
  builder.withDetail("gaStats", gaStats);
	}
 
Example 19
Source File: AppModeInfoProvider.java    From Hands-On-Reactive-Programming-in-Spring-5 with MIT License 4 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
   boolean appMode = rnd.nextBoolean();
   builder
      .withDetail("application-mode", appMode ? "experimental" : "stable");
}
 
Example 20
Source File: LauncherInfoContributor.java    From spring-cloud-formula with Apache License 2.0 4 votes vote down vote up
@Override
public void contribute(Info.Builder builder) {
    builder.withDetail("launcher", this.generateContent());
}