@marcingrzejszczak 这是关于您在此处给出的修复。我还面临此类 brave.baggage.CorrelationUpdateScope$Single 的内存泄漏问题,它占用了实例数量/大小的 55%,并且即使在一起工作了几个小时也没有被垃圾收集。我的环境 - spring boot 2.7.6 + spring cloud sleuth。这是我的 gradle 文件。
plugins {
id 'org.springframework.boot' version '2.7.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'com.github.sherter.google-java-format' version '0.9'
id 'jacoco'
id 'com.gorylenko.gradle-git-properties' version '2.3.1'
}
group = 'com.xxx.yyy'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
def lombokVersion ='1.18.22'
def openApiVersion = '1.6.7'
repositories {
mavenCentral()
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
ext {
set('springCloudVersion', "2021.0.5")
set('openFeignVersion', "11.8")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.springframework.session:spring-session-bom:2021.1.2"
}
}
dependencies {
implementation(
"org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j",
"org.springframework.cloud:spring-cloud-starter-circuitbreaker-reactor-resilience4j",
"org.springframework.cloud:spring-cloud-starter-gateway",
"org.springframework.cloud:spring-cloud-starter-openfeign",
'org.springframework.cloud:spring-cloud-starter-sleuth',
"io.github.openfeign:feign-jackson:${openFeignVersion}",
"org.springframework.boot:spring-boot-starter-security",
"org.springframework.boot:spring-boot-starter-oauth2-client",
"org.springframework.boot:spring-boot-starter-tomcat",
"org.springframework.security:spring-security-oauth2-resource-server",
"org.projectlombok:lombok:${lombokVersion}",
"org.freemarker:freemarker:2.3.31",
'commons-codec:commons-codec:1.15',
'org.apache.commons:commons-lang3:3.12.0',
"com.squareup.okhttp3:okhttp:4.9.3",
'net.logstash.logback:logstash-logback-encoder:6.6',
'org.springframework.boot:spring-boot-starter-actuator',
"org.springframework.boot:spring-boot-starter-cache",
"org.springframework.cloud:spring-cloud-sleuth-zipkin",
"commons-validator:commons-validator:1.7",
"org.springdoc:springdoc-openapi-webflux-core:${openApiVersion}",
"org.springdoc:springdoc-openapi-webflux-ui:${openApiVersion}",
"org.springdoc:springdoc-openapi-security:${openApiVersion}",
"org.springframework.boot:spring-boot-starter-webflux",
"org.springframework.session:spring-session-data-redis",
"io.lettuce:lettuce-core:6.1.8.RELEASE"
)
}
当我尝试设置 bean 时
@Bean
@Order(1)
CorrelationScopeCustomizer myCorrelationFieldsCorrelationScopeCustomizer(TracingProperties tracingProperties) {
return (builder) -> {
List<String> correlationFields = tracingProperties.getBaggage().getCorrelation().getFields();
for (String field : correlationFields) {
builder.add(CorrelationScopeConfig.SingleCorrelationField.newBuilder(BaggageField.create(field))
.build());
}
};
}
我收到错误“无法解析 TracingProperties”。我在当前的 gradle deps 中找不到 TracingProperties 类。有什么想法吗?