Class DefaultHealthAggregator

java.lang.Object
io.micronaut.management.health.aggregator.DefaultHealthAggregator
All Implemented Interfaces:
HealthAggregator<HealthResult>

@Singleton @Requires(beans=HealthEndpoint.class) public class DefaultHealthAggregator extends Object implements HealthAggregator<HealthResult>

Default implementation of HealthAggregator that creates a {status: , description: (optional) , details: } response. The top level object represents the most severe status found in the provided health results, or HealthStatus.UNKNOWN if none found. All registered indicators have their own {status: , description: (optional) , details: } object, keyed by the name of the HealthResult defined inside the details of the top level object.

Example: [status: "UP, details: [diskSpace: [status: UP, details: [:]], cpuUsage: ...]]

Since:
1.0
  • Constructor Details

    • DefaultHealthAggregator

      public DefaultHealthAggregator(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
      Default constructor.
      Parameters:
      applicationConfiguration - The application configuration.
  • Method Details

    • aggregate

      public org.reactivestreams.Publisher<HealthResult> aggregate(HealthIndicator[] indicators, HealthLevelOfDetail healthLevelOfDetail)
      Specified by:
      aggregate in interface HealthAggregator<HealthResult>
      Parameters:
      indicators - The health indicators to aggregate.
      healthLevelOfDetail - The HealthLevelOfDetail
      Returns:
      An aggregated response.
    • aggregate

      public org.reactivestreams.Publisher<HealthResult> aggregate(String name, org.reactivestreams.Publisher<HealthResult> results)
      Specified by:
      aggregate in interface HealthAggregator<HealthResult>
      Parameters:
      name - The name of the new health result
      results - The health results to aggregate.
      Returns:
      An aggregated HealthResult.
    • calculateOverallStatus

      protected io.micronaut.health.HealthStatus calculateOverallStatus(List<HealthResult> results)
      Parameters:
      results - A list of HealthResult
      Returns:
      The calculated overall health status
    • aggregateResults

      protected reactor.core.publisher.Flux<HealthResult> aggregateResults(HealthIndicator[] indicators)
      Parameters:
      indicators - An array of HealthIndicator
      Returns:
      The aggregated results from all health indicators
    • aggregateDetails

      protected Object aggregateDetails(List<HealthResult> results)
      Parameters:
      results - A list of health results
      Returns:
      The aggregated details for the results
    • buildResult

      @NullUnmarked protected HealthResult buildResult(io.micronaut.health.HealthStatus status, @Nullable Object details, HealthLevelOfDetail healthLevelOfDetail)
      Parameters:
      status - A HealthStatus
      details - The health status details
      healthLevelOfDetail - The HealthLevelOfDetail
      Returns:
      A Map with the results from the health status