Skip to content

Expose Spring Integration graph using an actuator #12331

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

Conversation

TYsewyn
Copy link
Contributor

@TYsewyn TYsewyn commented Mar 3, 2018

Based on the idea of @michael-simons (read this post), this PR will add the functionality of exposing the Spring Integration graph via JMX, Jersey, Spring MVC & WebFlux.

NB: Currently says @since 2.1.0 in the Javadoc.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 3, 2018
*/
@Configuration
@ConditionalOnClass(IntegrationGraphServer.class)
public class IntegrationGraphEndpointAutoConfiguration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to add this to spring.factories as well, see /spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/spring.factories.

This mechanism facilitates the fact that the autoconfiguration classes can be looked up instead are discovered via a package scan.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! For some reason it didn't get committed & pushed, but I do remember making the change 🤔
Anyway, will do that right away! Thanks!

@wilkinsona
Copy link
Member

@garyrussell @artembilan what do you think please?

@garyrussell
Copy link
Contributor

Fine with me; SI currently only supports MVC and WebFlux. Thanks Tim!

My only question is whether we should auto configure a IntegrationGraphServer by default when actuators are enabled.

This seems to be dependent on the presence of a bean; there is little overhead if it's never referenced.

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, we need to auto-configure an IntegrationGraphServer bean. And I think there is just enough to add one conditional into the IntegrationAutoConfiguration.IntegrationConfiguration.

@wilkinsona , I'd be glad to see your comments regarding code style.

Thanks

=== Response Structure

The response contains all Spring Integration components used within the application, as well as the links between them.
More info about the structure can be found in the https://docs.spring.io/spring-integration/reference/htmlsingle/#integration-graph[subchapter] for the integration graph in the reference documentation of Spring Integration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't use htmlsingle here as a cross-link. Consider to switch to this one: https://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#integration-graph.

Also I don't think that info is formal word. The information doesn't pull any questions from me 😄

@@ -0,0 +1,49 @@
/*
* Copyright 2012-2018 the original author or authors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

import org.springframework.integration.support.management.graph.IntegrationGraphServer;

/**
* {@link EnableAutoConfiguration Auto-configuration} for the {@link IntegrationGraphEndpoint}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that it's good idea to use imports only for JavaDocs.
Not sure how it is for Spring Boot, but in SI we disallow such a code via particular Checkstyle rule.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a similar restriction, but now I'm wondering if we should. It's fine for now.

@@ -0,0 +1,20 @@
/*
* Copyright 2012-2018 the original author or authors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really OK to have Copyright in the package-info.java files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, that's consistent with the others that we have.

/**
* Tests for generating documentation describing the {@link IntegrationGraphEndpoint}.
*
* @author Tim Ysewyn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @since 2.1.0 is applied to test classes as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we don't @since tests.

@@ -0,0 +1,49 @@
/*
* Copyright 2012-2018 the original author or authors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@TYsewyn
Copy link
Contributor Author

TYsewyn commented Mar 6, 2018

@garyrussell @artembilan I was thinking the same. Should I just put following under IntegrationAutoConfiguration.IntegrationConfiguration?

@ConditionalOnMissingBean
@Bean
public IntegrationGraphServer integrationGraphServer() {
	return new IntegrationGraphServer();
}

And is this PR the right one to do this? I would assume that you would like to backport this to 1.x if possible?

@artembilan
Copy link
Member

IMO that's the right place to do that.
And I don't think that we are going to backport it. There is no bug in the subject and there is always a workaround to do the same task using existing tools and hooks.

@TYsewyn
Copy link
Contributor Author

TYsewyn commented Mar 10, 2018

@artembilan @garyrussell last addition has been pushed.
If everything is fine for you I think this PR can be marked for 2.1.0?
Please let me know if you need me to change some things!

@snicoll
Copy link
Member

snicoll commented Mar 11, 2018

@TYsewyn we'll review and assign a milestone to this one in due course. Thanks!

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

snicoll pushed a commit to snicoll/spring-boot that referenced this pull request Apr 17, 2018
snicoll added a commit to snicoll/spring-boot that referenced this pull request Apr 17, 2018
@snicoll
Copy link
Member

snicoll commented Apr 17, 2018

I took an extensive look at this one and polished in my own fork. I didn't like the fact an IntegrationGraphServer is created as part of the main auto-configuration. That's a management concern so it shouldn't be there at all.

I've tried to make it conditional to the fact that the endpoint is not enabled but there is no easy way to do that as @ConditionalOnEnabledEndpoint only works on specific types. Perhaps we should revisit this a bit.

Also I didn't get why the endpoint is disabled by default. Is that really what we want?

@snicoll snicoll self-assigned this Apr 17, 2018
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 17, 2018
@snicoll snicoll added this to the Backlog milestone Apr 17, 2018
@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Apr 17, 2018
@artembilan
Copy link
Member

I had the same thought originally, Stephane. Right, the IntegrationGraphServer is a management concern, but from the other hand it exists in the core module and it is a simple as possible passive component. So, in the end I decided that it won't hurt to keep one more bean from the main auto-configuration.

If that is still a concern, let's consider to instantiate it from some actuator auto-configuration then!
The problem that it is an independent component and can be used even if a mentioned endpoint is disabled.

+1 do not make the endpoint disabled by default. Missed that part somehow during review...
Any explanations on the matter, @TYsewyn ?

Thanks

@snicoll
Copy link
Member

snicoll commented Apr 17, 2018

Thanks for the feedback.

and it is a simple as possible passive component

I am not sure I agree with that. There is an event listener that will build the graph once the context has refreshed. I see no reason to have that running if you don't use the actuator. If you need this feature, you can define the bean (as you'd probably do now).

The problem that it is an independent component and can be used even if a mentioned endpoint is disabled.

That's fine but IMO there is a difference between providing this (that only the endpoint would be using) and providing this when the endpoint is required. My preference is for the latter but unfortunately, that's not easy to implement.

+1 do not make the endpoint disabled by default.

I've already changed that in my polish commit

@artembilan
Copy link
Member

Stephane,

I think we're good to go with your polishing: you have addressed all the concerns! 👍

@TYsewyn
Copy link
Contributor Author

TYsewyn commented Apr 18, 2018

I disabled the endpoint because there wasn't an IntegrationGraphServer bean present in the auto-configuration, so it didn't make any sense to bootstrap that endpoint by default.
We added one later and I forgot to switch it on by default when adding the bean.

@@ -105,6 +105,10 @@ exchanges).
|Displays arbitrary application info.
|Yes

|`integrationgraph`
|Exposes the Spring Integration graph.
|No
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snicoll Can you update this in your polishing commit to indicate that it will be enabled by default? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, thanks for the ping.

@snicoll
Copy link
Member

snicoll commented Apr 19, 2018

you have addressed all the concerns

I did not I think. I wish that the IntegrationGraphServer wasn't created at all if the endpoint is disabled or when Spring Integration is not enabled.

@artembilan how can I know that SI is enabled on a project? Is there a typical bean I could look for?

@artembilan
Copy link
Member

@snicoll ,

I think you can create IntegrationGraphServer conditionally when an endpoint is enabled.
On the other hand our main IntegrationAutoConfiguration relies on the @ConditionalOnClass(EnableIntegration.class). Maybe that would be enough here as well?
If the story is still about an excluded IntegrationAutoConfiguration, then we can consider a condition against the IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME bean which is a type of DefaultHeaderChannelRegistry. That is one of those which is registered by that @EnableIntegration.

Hope that helps.

@snicoll
Copy link
Member

snicoll commented Apr 19, 2018

Thanks for the feedback @artembilan

I think you can create IntegrationGraphServer conditionally when an endpoint is enabled.

Actually I can't at the moment, so we'll have to change the condition if you want to make that happen.

@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Apr 23, 2018
@snicoll
Copy link
Member

snicoll commented Apr 23, 2018

I've created #12945 to improve the condition. If this is merged, I can prevent IntegrationGraphServer to be created when then endpoint is disabled.

@snicoll snicoll modified the milestones: Backlog, 2.1.0.M1 Apr 25, 2018
@snicoll
Copy link
Member

snicoll commented Apr 25, 2018

@TYsewyn that's now merged in master. Thanks a lot!

@snicoll snicoll closed this in 03cf4fb Apr 25, 2018
snicoll added a commit that referenced this pull request Apr 25, 2018
…raph

* pr/12331:
  Polish "Add actuator endpoint for exposing the Spring Integration graph"
  Add actuator endpoint for exposing the Spring Integration graph
@TYsewyn
Copy link
Contributor Author

TYsewyn commented Apr 26, 2018

Thanks everyone for the valuable feedback!

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

Successfully merging this pull request may close these issues.

8 participants