"httptrace" endpoint of Spring Boot Actuator doesn't exist anymore with Spring Boot 2.2.0
Asked Answered
S

4

51

With Spring Boot 2.2.0 the "httptrace" Actuator endpoint doesn't exist anymore. How can I get this functionality back?

Strophanthus answered 30/11, 2019 at 11:11 Comment(1)
S
98

The functionality has been removed by default in Spring Boot 2.2.0.

As a workaround, add this configuration to the Spring environment:

management.endpoints.web.exposure.include: httptrace

and provide an HttpTraceRepository bean like this:

@Configuration
// @Profile("actuator-endpoints")
// if you want: register bean only if profile is set
public class HttpTraceActuatorConfiguration {

    @Bean
    public HttpTraceRepository httpTraceRepository() {
        return new InMemoryHttpTraceRepository();
    }

}

http://localhost:8080/actuator/httptrace works again.

Strophanthus answered 30/11, 2019 at 11:11 Comment(2)
In my case @Profile annotation was unnecessary - after remove it its working !Marius
can confirm the HttpTraceRepository is neededNecrophobia
M
7

You need to enable httptrace by having following application properties. By default it is disabled

management.trace.http.enabled: true
management.endpoints.web.exposure.include: httptrace

and Requires an HttpTraceRepository bean. You can use Your own Custom implementation or InMemoryHttpTraceRepository

Marivelmariya answered 14/1, 2020 at 1:25 Comment(5)
Hi! Unfortunately this is not right. At least not for Spring Boot 2.2.0 and above. See release notes :)github.com/spring-projects/spring-boot/wiki/…Strophanthus
What is not right, i have tested it with 2.2.2.RELEASE, i found the information from documentation docs.spring.io/spring-boot/docs/current/reference/html/…Marivelmariya
Well... strange .. according to the official 2.2.0 release notes one has to provide a bean and that's the only way I got it work (github.com/spring-projects/spring-boot/wiki/…)Strophanthus
this worked for me. thanks ravthiru, missleading post comment by phip1611...Fakery
@FacundoLaxalde @Marivelmariya I have an update on this. management.endpoints.web.exposure.include: httptrace (or '*') is definetly required, yes. But according to the release notes (and my own testing) management.trace.http.enabled: true is not required, although it can be used to disable this feature even if a HttpTraceRepository bean is present. Sorry for the circumstances!Strophanthus
J
0

For Spring Boot 3+, you should use:

@Bean
public InMemoryHttpExchangeRepository createTraceRepository() {
  return new InMemoryHttpExchangeRepository();
}

More details can be found in the migratuon guide

Jobi answered 23/4, 2024 at 7:44 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Killam
O
0

Here's the complete setup for enabling and using the httpexchanges functionality in Spring Boot 3.

Configuration Class

package com.openclassrooms.watchlist.actuator;

import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository;
import org.springframework.boot.actuate.web.exchanges.InMemoryHttpExchangeRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HttpTraceActuatorConfiguration {

    @Bean
    public HttpExchangeRepository createTraceRepository() {
        return new InMemoryHttpExchangeRepository();
    }
}

application.properties

management.endpoints.web.exposure.include=httpexchanges
management.httpexchanges.recording.enabled=true

This setup will enable you to record and access HTTP exchange information using the /actuator/httpexchanges endpoint Test

Ossiferous answered 3/7, 2024 at 10:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.