resteasy / resteasy-spring-boot

Apache License 2.0
123 stars 51 forks source link

How to integrate with Spring boot actuator? #123

Open ortizman opened 2 years ago

ortizman commented 2 years ago

I am using this starter to expose JAX-RS resources. Now I want to integrate Spring boot Actuator Simply, I insert the dependency in my build.gradle

Dependency implementation 'org.springframework.boot:spring-boot-starter-actuator'.

LOGS INFO 1386771 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'. But I can't access it.

Is there any alternative to access these endpoints without having to migrate to Jersey?

liweinan commented 2 years ago

Hi @ortizman ,

I used the example in the project:

And added actuator into pom.xml according to the doc:

image

Then I started the sample-app:

image

Then I tried to access the endpoint provided by actuator:

➤ curl http://localhost:8080/actuator

From the output I can see the actuator output:

image

Does this solve your problem?

jbaris commented 2 years ago

As doc https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.monitoring

Actuator is supported natively with Spring MVC, Spring WebFlux, and Jersey.

The sample project you mentioned uses Spring MVC https://github.com/resteasy/resteasy-spring-boot/blob/main/sample-app/pom.xml#L38 that's why actuator is working.

I think @ortizman is asking for a native support for Resteasy (in the same way of the above technologies)

This native support should cover the http tracing features of actuator https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.tracing

liweinan commented 2 years ago

@jbaris I created a Pull Request to verify the actuator behavior :

I deployed the sample into WildFly:

image


image

And I can see that webmvc is the core part that enable the actuator:

image

If I enable the above webmvc and then the actuator can work:

image

I need to check the detail implementation of spring-webmvc to see how it works to support actuator.

jbaris commented 2 years ago

Just for the record: If you are using a JaxRS application like: @ApplicationPath("") (note this app runs on the root path)

This application will conflict with the spring-mvc path for Actuator. To solve this, just use:

management.server.port=8085 for open Actuator on another Tomcat instance

or:

spring.mvc.servlet.path=/actuator to run spring the mvc endpoint at another path.