Search code examples
spring-cloud-sleuth

How to remove WARN message using Spring Cloud Sleuth and Spring Cloud Gateway


I need to log traces in the Netty logs, so I added this configuration:

@Configuration
public class SleuthGWConfiguration {

    @Bean
    public HttpClientCustomizer customizer(HttpTracing httpTracing) {
        return (c) -> {
            return ReactorNettyHttpTracing.create(httpTracing).decorateHttpClient(c);


        };
    }
}

and the logs contain traces as expected:

[2m2022-05-18 18:16:16.306[0;39m [32mDEBUG [,,][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mreactor.netty.http.server.HttpServer    [0;39m [2m:[0;39m [08685324-1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:59765] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@130d2eee
[2m2022-05-18 18:16:16.910[0;39m [32mDEBUG [,efbd8bcbe33f76e3,efbd8bcbe33f76e3][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.netty.http.client.HttpClientConnect   [0;39m [2m:[0;39m [1a19d87a-1, L:/127.0.0.1:59767 - R:localhost/127.0.0.1:8085] Handler is being applied: {uri=http://localhost:8085/get, method=GET}
[2m2022-05-18 18:16:16.936[0;39m [32mDEBUG [,efbd8bcbe33f76e3,761f2b4fd9a180ba][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.n.http.client.HttpClientOperations    [0;39m [2m:[0;39m [1a19d87a-1, L:/127.0.0.1:59767 - R:localhost/127.0.0.1:8085] Received response (auto-read:false) : [Server=gunicorn/19.9.0, Date=Wed, 18 May 2022 16:16:16 GMT, Connection=keep-alive, Content-Type=application/json, Access-Control-Allow-Origin=*, Access-Control-Allow-Credentials=true, content-length=1382]
[2m2022-05-18 18:16:16.944[0;39m [32mDEBUG [,efbd8bcbe33f76e3,efbd8bcbe33f76e3][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.n.http.client.HttpClientOperations    [0;39m [2m:[0;39m [1a19d87a-1, L:/127.0.0.1:59767 - R:localhost/127.0.0.1:8085] Received last HTTP packet
[2m2022-05-18 18:16:16.966[0;39m [32mDEBUG [,efbd8bcbe33f76e3,efbd8bcbe33f76e3][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.n.http.server.HttpServerOperations    [0;39m [2m:[0;39m [08685324-1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:59765] Last HTTP response frame

but a WARN message with a big stack trace appears at application start-up (complete stack trace is here):

[36mo.s.c.s.a.i.w.SkipPatternConfiguration  [0;39m [2m:[0;39m Most likely, there is an actuator endpoint that indirectly references an instrumented HTTP client. An exception was thrown during bean initialization. Will ignore that exception

After investigation, I found the related issue. It seems that this does not cause real problems, but I'd like to know if it's possible creating a configuration which prevents the exception to be thrown at startup.

The sample project is available here.


Solution

  • Just set a property logging.level.org.springframework.cloud.sleuth.autoconfig.instrument.web.SkipPatternConfiguration=ERROR. You can do it e.g. via application.yml

    UPDATE:

    With this issue https://github.com/spring-cloud/spring-cloud-sleuth/issues/2166 we're lowering the noise by lowering the logging severity