Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a ConcurrentCompositeHealthIndicator #15836

Conversation

RikEnde
Copy link

@RikEnde RikEnde commented Feb 2, 2019

See #2652

I submitted a PR for this issue before, but it wasn't very good. I hope this one is better.

Problem:
Right now, invoking the health endpoint lead to a synchronous invocation of all underlying HealthIndicator instance(s) that have been configured. It would be nice to offer an option to run these in parallel instead.

Real world example:
I have a number of HealtIndicator components that poll remote systems and report on latency and status, and the latency really adds up, especially if there are time-outs involved.

Solution:
This PR adds a ConcurrentCompositeHealthIndicator that can run the HealthIndicator instances on the ThreadPoolTaskExecutor.

Usage in code:

    @Bean
    public HealthEndpoint healthEndpoint(HealthAggregator healthAggregator,
                                         HealthIndicatorRegistry registry,
                                         ThreadPoolTaskExecutor executor
                                         ) {
        return new HealthEndpoint(
            new ConcurrentCompositeHealthIndicator(healthAggregator, registry, executor, Duration.ofMillis(1100)));
    }

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 2, 2019
Unit test to verify output is identical to CompositeHealthIndicator
Unit test to verify output is identical to CompositeHealthIndicator

test must work
@RikEnde RikEnde force-pushed the 2.1.x-add-concurrent-composite-health-indicator branch from 263050e to 5a99a82 Compare February 11, 2019 21:06
@RikEnde RikEnde closed this Feb 16, 2019
@snicoll
Copy link
Member

snicoll commented Feb 16, 2019

@RikEnde did you mean to close this PR?

@RikEnde
Copy link
Author

RikEnde commented Feb 16, 2019

While working on this, I found it could be solved at the application level once we move to spring boot 2.1.x

@snicoll I'm really sorry for wasting your time. I felt less good about this PR every day, and now that I have a workaround, I can't justify working on it during the day.

@wilkinsona wilkinsona removed the status: waiting-for-triage An issue we've not yet triaged label Feb 26, 2019
@CLOUGH
Copy link

CLOUGH commented Jan 5, 2021

@RikEnde could you share the workaround that you found.

@RikEnde
Copy link
Author

RikEnde commented Jan 5, 2021

@RikEnde could you share the workaround that you found.

The code from this PR could be implemented entirely in domain code, requiring no framework changes. However, this was 2 years old. It doesn't even compile against the current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants