I need to configure the spring boot actuator endpoints programmatically in my autoconfigure project. Right now, I implemented EnvironmentPostProcessor to update the management.endpoints.web.path-mapping (as mentioned in https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.monitoring.customizing-management-server-context-path) The better approach for this to have a cleaner programmatic api for PathMapper. Hence raising an issue to consider this as an enhancement request.

Comment From: wilkinsona

The auto-configured PathMapper isn't @ConditionalOnMissingBean at the moment:

https://github.com/spring-projects/spring-boot/blob/1793cee00fc660891bf44860e10f0f04ca15c92e/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java#L75-L80

If we made it @ConditionalOnMissingBean you could define your own PathMapper bean and take complete programmatic control over how the endpoints are mapped. Would that meet your needs?

Comment From: KalyanAbbaraju

Thanks @wilkinsona @ConditionalOnMissingBean on PathMapper is helpful for my requirements.

Comment From: mhalbritter

We will make PathMapper a @ConditionalOnMissingBean then.

Comment From: mhalbritter

Making the PathMapper a @ConditionalOnMissingBean doesn't quite work out. There can be multiple PathMapper in the context, which are queried in order until one returns something which not null, and then this path is used as endpoint path.

@kamilszymanski Can you please try to create your own PathMapper bean and annotate it with @Order(Ordered.HIGHEST_PRECEDENCE)? As long as you don't return null in your PathMapper, Spring Boot's mapper will never be queried, giving you total control over the endpoints.

Comment From: kamilszymanski

@mhalbritter most probably you wanted to mention @KalyanAbbaraju instead of me

Comment From: mhalbritter

@mhalbritter most probably you wanted to mention @KalyanAbbaraju instead of me

Oh, sorry about that. Yeah, i meant to ping @KalyanAbbaraju.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.