@Test public void downWithExceptionHandling() throws Exception { HealthAggregator healthAggregator = mock(HealthAggregator.class); ApplicationAliveIndicator healthIndicator = mock(ApplicationAliveIndicator.class); when(healthIndicator.health()).thenThrow(new RuntimeException("fooException")); Map<String, ApplicationAliveIndicator> healthIndicators = new LinkedHashMap<>(); healthIndicators.put("foo", healthIndicator); when(applicationContext.getBeansOfType(ApplicationAliveIndicator.class)).thenReturn(healthIndicators); extendedHealthEndpoint = new AliveHealthEndpoint("healthIndicatorfoo", healthAggregator); extendedHealthEndpoint.setApplicationContext(applicationContext); this.extendedHealthMvcEndpoint = new ExtendedHealthMvcEndpoint(this.extendedHealthEndpoint); ResponseEntity<Health> result = (ResponseEntity<Health>) this.extendedHealthMvcEndpoint.invoke(null); Map<String, Object> expectedHealthDetails = new LinkedHashMap<>(); expectedHealthDetails.put("error", "java.lang.RuntimeException: fooException"); assertThat(result.getBody().getDetails(), is(expectedHealthDetails)); assertThat(result.getStatusCode(), is(HttpStatus.SERVICE_UNAVAILABLE)); assertThat(result.getBody().getStatus(), is(Status.DOWN)); }
public HealthService(HealthAggregator healthAggregator, Map<String, org.springframework.boot.actuate.health.HealthIndicator> healthIndicators) { Assert.notNull(healthAggregator, "HealthAggregator must not be null"); Assert.notNull(healthIndicators, "HealthIndicators must not be null"); CompositeHealthIndicator healthIndicator = new CompositeHealthIndicator( healthAggregator); for (Map.Entry<String, org.springframework.boot.actuate.health.HealthIndicator> entry : healthIndicators.entrySet()) { healthIndicator.addHealthIndicator(getKey(entry.getKey()), entry.getValue()); } this.healthIndicators = healthIndicators; this.healthIndicator = healthIndicator; }
public EndpointAutoConfiguration( ObjectProvider<HealthAggregator> healthAggregatorProvider, ObjectProvider<Map<String, HealthIndicator>> healthIndicatorsProvider, ObjectProvider<List<InfoContributor>> infoContributorsProvider, ObjectProvider<Collection<PublicMetrics>> publicMetricsProvider, ObjectProvider<TraceRepository> traceRepositoryProvider) { this.healthAggregator = healthAggregatorProvider.getIfAvailable(); this.healthIndicators = healthIndicatorsProvider.getIfAvailable(); this.infoContributors = infoContributorsProvider.getIfAvailable(); this.publicMetrics = publicMetricsProvider.getIfAvailable(); this.traceRepository = traceRepositoryProvider.getIfAvailable(); }
/** * Create a new {@link HealthIndicator} instance. * @param healthAggregator the health aggregator * @param healthIndicators the health indicators */ public HealthEndpoint(HealthAggregator healthAggregator, Map<String, HealthIndicator> healthIndicators) { super("health", false); Assert.notNull(healthAggregator, "HealthAggregator must not be null"); Assert.notNull(healthIndicators, "HealthIndicators must not be null"); CompositeHealthIndicator healthIndicator = new CompositeHealthIndicator( healthAggregator); for (Map.Entry<String, HealthIndicator> entry : healthIndicators.entrySet()) { healthIndicator.addHealthIndicator(getKey(entry.getKey()), entry.getValue()); } this.healthIndicator = healthIndicator; }
public PrometheusEndpoint(Collection<PublicMetrics> publicMetrics, PrometeusMetricNameConverter prometeusMetricNameConverter, Map<String, HealthIndicator> healthIndicators, HealthAggregator healthAggregator) { super("prometheus", false, true); this.publicMetrics = publicMetrics; this.prometeusMetricNameConverter = prometeusMetricNameConverter; this.healthIndicators = healthIndicators; this.healthAggregator = healthAggregator; }
@Bean @ConditionalOnMissingBean @Autowired public PrometheusEndpoint prometheusEndpoint(Collection<PublicMetrics> publicMetrics, PrometeusMetricNameConverter prometeusMetricNameConverter, Map<String, HealthIndicator> healthIndicators, HealthAggregator healthAggregator) { return new PrometheusEndpoint(publicMetrics, prometeusMetricNameConverter, healthIndicators, healthAggregator); }
@Autowired public DiscoveryCompositeHealthIndicator(HealthAggregator healthAggregator, List<DiscoveryHealthIndicator> indicators) { super(healthAggregator); for (DiscoveryHealthIndicator indicator : indicators) { Holder holder = new Holder(indicator); addHealthIndicator(indicator.getName(), holder); healthIndicators.add(holder); } }
@Bean @ConditionalOnProperty(value = "spring.cloud.discovery.client.composite-indicator.enabled", matchIfMissing = true) @ConditionalOnBean(DiscoveryHealthIndicator.class) public DiscoveryCompositeHealthIndicator discoveryCompositeHealthIndicator( HealthAggregator aggregator, List<DiscoveryHealthIndicator> indicators) { return new DiscoveryCompositeHealthIndicator(aggregator, indicators); }
@Autowired public SVNHealthIndicator(ConfigurationService<SVNConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, SVNService svnService, TransactionService transactionService, SVNClient svnClient) { super(configurationService, securityService, healthAggregator); this.svnService = svnService; this.transactionService = transactionService; this.svnClient = svnClient; }
@Autowired public GitHubHealthIndicator( ConfigurationService<GitHubEngineConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, OntrackGitHubClientFactory gitHubClientFactory) { super(configurationService, securityService, healthAggregator); this.gitHubClientFactory = gitHubClientFactory; }
@Autowired public GitLabHealthIndicator( ConfigurationService<GitLabConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, OntrackGitLabClientFactory gitLabClientFactory) { super(configurationService, securityService, healthAggregator); this.gitLabClientFactory = gitLabClientFactory; }
/** Registers health for any components, even those not in this jar. */ @Bean ZipkinHealthIndicator zipkinHealthIndicator(HealthAggregator healthAggregator) { return new ZipkinHealthIndicator(healthAggregator); }
ZipkinHealthIndicator(HealthAggregator healthAggregator) { super(healthAggregator); }
@Bean public HealthEndpoint endpoint(HealthAggregator healthAggregator, Map<String, HealthIndicator> healthIndicators) { return new HealthEndpoint(healthAggregator, healthIndicators); }
@Bean public HealthAggregator healthAggregator() { return new OrderedHealthAggregator(); }
@Bean HealthCheckHandler healthCheckHandler(ApplicationInfoManager applicationInfoManager, HealthAggregator healthAggregator, Map<String, HealthIndicator> healthIndicators) { return new BootHealthCheckHandler(applicationInfoManager, healthAggregator, healthIndicators); }
public BootHealthCheckHandler(ApplicationInfoManager applicationInfoManager, HealthAggregator aggregator, Map<String, HealthIndicator> healthIndicators) { this.applicationInfoManager = Objects.requireNonNull(applicationInfoManager, "applicationInfoManager"); this.aggregateHealth = new CompositeHealthIndicator(aggregator, healthIndicators); }
@Autowired public ArtifactoryHealthIndicator(ConfigurationService<ArtifactoryConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, ArtifactoryClientFactory clientFactory) { super(configurationService, securityService, healthAggregator); this.clientFactory = clientFactory; }
@Autowired public JenkinsHealthIndicator(ConfigurationService<JenkinsConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, JenkinsClientFactory jenkinsClientFactory) { super(configurationService, securityService, healthAggregator); this.jenkinsClientFactory = jenkinsClientFactory; }
@Autowired public GitHealthIndicator(ConfigurationService<BasicGitConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, GitRepositoryClientFactory repositoryClientFactory) { super(configurationService, securityService, healthAggregator); this.repositoryClientFactory = repositoryClientFactory; }
protected ConfigurationHealthIndicator(ConfigurationService<T> configurationService, SecurityService securityService, HealthAggregator healthAggregator) { this.configurationService = configurationService; this.securityService = securityService; this.healthAggregator = healthAggregator; }
@Autowired public JIRAHealthIndicator(ConfigurationService<JIRAConfiguration> configurationService, SecurityService securityService, HealthAggregator healthAggregator, JIRASessionFactory sessionFactory) { super(configurationService, securityService, healthAggregator); this.sessionFactory = sessionFactory; }
public EurekaHealthCheckHandler(HealthAggregator healthAggregator) { Assert.notNull(healthAggregator, "HealthAggregator must not be null"); this.healthIndicator = new CompositeHealthIndicator(healthAggregator); }
/** * Create new ExtendedHealthEndpoint. * * @param id part of the endpoint URL * @param healthAggregator usually a new instance of OrderedHealthAggregator * @param indicatorMarkerInterface * @param excludeIndicatorMarkerInterface indicator class that should be excluded, can be null */ public ExtendedHealthEndpoint(String id, HealthAggregator healthAggregator, Class<T> indicatorMarkerInterface, Class<? extends HealthIndicator> excludeIndicatorMarkerInterface) { super(id); this.healthAggregator = healthAggregator; this.indicatorMarkerInterface = indicatorMarkerInterface; this.excludeIndicatorMarkerInterface = excludeIndicatorMarkerInterface; LOG.info("Registered ExtendedHealthEndpoint with id " + id); }
/** * Create new AliveHealthEndpoint. * * @param id part of the endpoint URL * @param healthAggregator usually a new instance of OrderedHealthAggregator */ public AliveHealthEndpoint(String id, HealthAggregator healthAggregator) { super(id, healthAggregator, ApplicationAliveIndicator.class); }
/** * Create new BasicHealthEndpoint. * * @param id part of the endpoint URL * @param healthAggregator usually a new instance of OrderedHealthAggregator */ public BasicHealthEndpoint(String id, HealthAggregator healthAggregator) { super(id, healthAggregator, HealthIndicator.class, DetailHealthIndicator.class); }
/** * Create new DetailHealthEndpoint. * * @param id part of the endpoint URL * @param healthAggregator usually a new instance of OrderedHealthAggregator */ public DetailHealthEndpoint(String id, HealthAggregator healthAggregator) { super(id, healthAggregator, DetailHealthIndicator.class); }