Spring Cloud Sleuth 检测不断打印 TODO before/after removeServiceName=

Spring Cloud Sleuth instrumentation constantly prints TODO before/after removeServiceName=

从 Spring Boot 2.3 迁移到 2.6 后,我在 Spring Cloud Sleuth 中出现了奇怪的行为。 仪器不断向控制台打印这些消息

2022-02-10 11:59:46.804  INFO [SERVICE,4b9b266d4e1cf475,0bd79e17d007e0ce] 6412 --- [nio-8890-exec-6] o.s.c.s.i.jdbc.TraceListenerStrategy     : TODO before removeServiceName=serviceDataSource
2022-02-10 11:59:46.804  INFO [SERVICE,4b9b266d4e1cf475,0bd79e17d007e0ce] 6412 --- [nio-8890-exec-6] o.s.c.s.i.jdbc.TraceListenerStrategy     : TODO after removeServiceName=serviceDataSource

我在 Spring Cloud Sleuth 源代码

中找到了这段代码
    void afterGetConnection(CON connectionKey, @Nullable Connection connection, String dataSourceName,
            @Nullable Throwable t) {
        if (log.isTraceEnabled()) {
            log.trace("After get connection [" + connectionKey + "]. Current span is [" + tracer.currentSpan() + "]");
        }
        ConnectionInfo connectionInfo = this.openConnections.get(connectionKey);
        SpanAndScope connectionSpan = connectionInfo.span;
        if (connection != null) {
            log.info("TODO before removeServiceName=" + connectionInfo.remoteServiceName);
            parseAndSetServerIpAndPort(connectionInfo, connection, dataSourceName);
            log.info("TODO after removeServiceName=" + connectionInfo.remoteServiceName);
            if (connectionSpan != null) {
                connectionSpan.getSpan().remoteServiceName(connectionInfo.remoteServiceName);
                connectionSpan.getSpan().remoteIpAndPort(connectionInfo.url.getHost(), connectionInfo.url.getPort());
            }
        }

这是正确的行为吗?如何禁用这些消息?或者迁移后我的数据库连接或 Spring Cloud Sleuth 出现问题?

此问题已修复 https://github.com/spring-cloud/spring-cloud-sleuth/issues/2069 并将很快发布。在那之前,您可以将 class 的日志记录级别设置为 ERROR logging.level.org.springframework.cloud.sleuth.instrument.jdbc=ERROR