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

Custom actuator endpoint not working in 3.4.0-RC1 #42987

Closed
nicolasb29 opened this issue Nov 4, 2024 · 6 comments
Closed

Custom actuator endpoint not working in 3.4.0-RC1 #42987

nicolasb29 opened this issue Nov 4, 2024 · 6 comments
Assignees

Comments

@nicolasb29
Copy link

nicolasb29 commented Nov 4, 2024

Hi,

I have a custom actuator endpoint that works perfectly in Spring Boot 3.3.5, but it no longer functions in Spring Boot 3.4.0-RC1 (I have a 404 error because the endpoint is not registered).

I created an example project to demonstrate the issue. The source code is available at this GitHub repository. The main branch uses Spring Boot 3.3.5, while the 3.4.0-RC1_deprecated branch is based on Spring Boot 3.4.0-RC1.

I have also tried the reworked method with access on 3.4.0-RC1_access, but it does not resolve the issue either.

Test results can be found here

The code of the custom actuator endpoint:

@Component
@Endpoint(id = "custom")
public class TestActuatorEndpoint {

    @ReadOperation
    public String read() {
        return "OK";
    }
}

The configuration:

spring:
  application:
   name: testactuator
management:
  endpoints:
    enabled-by-default: false
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      enabled: true
  cors:
    allowed-origins: "*"
    allowed-methods: GET
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 4, 2024
@philwebb philwebb self-assigned this Nov 4, 2024
@nicolasb29
Copy link
Author

It seems that the endpoint isn't invocable because operation was filtered (list is empty) due to this line.

@philwebb
Copy link
Member

philwebb commented Nov 4, 2024

In Spring Boot 3.3 the management.endpoints.enabled-by-default property was exclusively handled by OnAvailableEndpointCondition, in 3.4 it's handled at a higher level.

We're reading management.endpoints.enabled-by-default=false as a signal to disable any endpoints that haven't been explicitly enabled.

To fix things, you can do the following:

spring:
  application:
   name: testactuator
management:
  endpoints:
    enabled-by-default: false
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      enabled: true
    custom:
      enabled: true
  cors:
    allowed-origins: "*"
    allowed-methods: GET

(or use the new access properties).

I'm not sure if we should treat this as a regression or not. Arguably, it's more consistent the way things are in 3.4.

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Nov 4, 2024
@nicolasb29
Copy link
Author

I had added manually the endpoint and it work well but in my case we have dozens of custom actuators endpoints managed by a team and hundreds of applications using them and managed by a lot developers, so it can be seen as a regression. But I agree with you that it is more comprehensible.

@wilkinsona
Copy link
Member

I think we should leave things as-is for 3.4 but update the release notes to call out that enabled-by-default now applies irrespective of the use of @ConditionalOnAvailableEndpoint.

@wilkinsona
Copy link
Member

I've added something to the end of this section in the release notes.

@philwebb philwebb removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Nov 5, 2024
@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
@philwebb
Copy link
Member

philwebb commented Nov 5, 2024

Thanks @wilkinsona, I'm going to close this one.

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

No branches or pull requests

4 participants