英文:
Upgrade to spring boot 3.1 breaks my otel exporter
问题
我更新了otel导出器配置,从
SPRING_SLEUTH_OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo.xxx.svc.cluster.local:4317
到
MANAGEMENT_OTLP_TRACING_ENDPOINT=http://tempo.xxx.svc.cluster.local:4317
现在日志显示以下错误:
{
"@timestamp": "2023-06-08T17:56:22.333359047-03:00",
"level": "ERROR",
"message": "Failed to export spans. The request could not be executed. Full error message: Connection reset",
"traceId": "",
"spanId": "",
"logger": "io.opentelemetry.exporter.internal.okhttp.OkHttpExporter",
"thread": "OkHttp http://tempo.observability.svc.cluster.local:4317/..."
}
有人遇到类似的问题吗?
版本信息:
- spring boot: 3.1
- micrometer-tracing: 1.1
- opentelemetry-exporter-otlp: 1.26.0
- tempo: 2.1
英文:
After upgrading from spring boot 2.7.10 (using sleuth) to 3.1 (micrometer-tracing) I updated my otel exporter config from
SPRING_SLEUTH_OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo.xxx.svc.cluster.local:4317
to
MANAGEMENT_OTLP_TRACING_ENDPOINT=http://tempo.xxx.svc.cluster.local:4317
The log is now showing the following error:
{
"@timestamp": "2023-06-08T17:56:22.333359047-03:00",
"level": "ERROR",
"message": "Failed to export spans. The request could not be executed. Full error message: Connection reset",
"traceId": "",
"spanId": "",
"logger": "io.opentelemetry.exporter.internal.okhttp.OkHttpExporter",
"thread": "OkHttp http://tempo.observability.svc.cluster.local:4317/..."
}
Has anyone had similar issue ?
version:
- spring boot: 3.1
- micrometer-tracing: 1.1
- opentelemetry-exporter-otlp: 1.26.0
- tempo: 2.1
答案1
得分: 1
Spring Boot 3.1 OtlpAutoConfiguration 使用 OtlpHttpSpanExporter,因此我们需要覆盖配置如下:
@Configuration
@EnableConfigurationProperties(OtlpProperties.class)
public class OtlpConfiguration {
// OtlpAutoConfiguration 默认使用 HTTP,我们将其更新为使用 GRPC
// https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpAutoConfiguration.java
@Bean
public OtlpGrpcSpanExporter otlpExporter(final OtlpProperties properties) {
final OtlpGrpcSpanExporterBuilder builder =
OtlpGrpcSpanExporter.builder()
.setEndpoint(properties.getEndpoint())
.setTimeout(properties.getTimeout())
.setCompression(String.valueOf(properties.getCompression()).toLowerCase());
for (final Entry<String, String> header : properties.getHeaders().entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
return builder.build();
}
}
这是您提供的代码的翻译部分。
英文:
Spring boot 3.1 OtlpAutoConfiguration uses OtlpHttpSpanExporter so we need to override the configuration with:
@Configuration
@EnableConfigurationProperties(OtlpProperties.class)
public class OtlpConfiguration {
// OtlpAutoConfiguration use HTTP by default, we update it to use GRPC
// https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpAutoConfiguration.java
@Bean
public OtlpGrpcSpanExporter otlpExporter(final OtlpProperties properties) {
final OtlpGrpcSpanExporterBuilder builder =
OtlpGrpcSpanExporter.builder()
.setEndpoint(properties.getEndpoint())
.setTimeout(properties.getTimeout())
.setCompression(String.valueOf(properties.getCompression()).toLowerCase());
for (final Entry<String, String> header : properties.getHeaders().entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
return builder.build();
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论