Java Code Examples for org.springframework.boot.actuate.health.Health.Builder#withDetail()

The following examples show how to use org.springframework.boot.actuate.health.Health.Builder#withDetail() . 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: RefreshScopeHealthIndicator.java    From spring-cloud-commons with Apache License 2.0 6 votes vote down vote up
@Override
protected void doHealthCheck(Builder builder) throws Exception {
	RefreshScope refreshScope = this.scope.getIfAvailable();
	if (refreshScope != null) {
		Map<String, Exception> errors = new HashMap<>(refreshScope.getErrors());
		errors.putAll(this.rebinder.getErrors());
		if (errors.isEmpty()) {
			builder.up();
		}
		else {
			builder.down();
			if (errors.size() == 1) {
				builder.withException(errors.values().iterator().next());
			}
			else {
				for (String name : errors.keySet()) {
					builder.withDetail(name, errors.get(name));
				}
			}
		}
	}
}
 
Example 2
Source File: ConfigServerHealthIndicator.java    From spring-cloud-config with Apache License 2.0 6 votes vote down vote up
@Override
protected void doHealthCheck(Builder builder) throws Exception {
	PropertySource<?> propertySource = getPropertySource();
	builder.up();
	if (propertySource instanceof CompositePropertySource) {
		List<String> sources = new ArrayList<>();
		for (PropertySource<?> ps : ((CompositePropertySource) propertySource)
				.getPropertySources()) {
			sources.add(ps.getName());
		}
		builder.withDetail("propertySources", sources);
	}
	else if (propertySource != null) {
		builder.withDetail("propertySources", propertySource.toString());
	}
	else {
		builder.unknown().withDetail("error", "no property sources located");
	}
}
 
Example 3
Source File: JobExecutorHealthIndicator.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Override
protected void doHealthCheck(Builder builder) throws Exception {
  boolean active = jobExecutor.isActive();
  if (active) {
    builder = builder.up();
  } else {
    builder = builder.down();
  }
  builder.withDetail("jobExecutor", Details.from(jobExecutor));
}
 
Example 4
Source File: JobExecutorHealthIndicator.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void doHealthCheck(Builder builder) throws Exception {
  boolean active = jobExecutor.isActive();
  if (active) {
    builder = builder.up();
  } else {
    builder = builder.down();
  }
  builder.withDetail("jobExecutor", Details.from(jobExecutor));
}
 
Example 5
Source File: MyHealthIndicator.java    From spring-boot-inside with MIT License 4 votes vote down vote up
@Override
protected void doHealthCheck(Builder builder) throws Exception {
	builder.status(Status.UP);
	builder.withDetail("hello", "world");
}