Spring Boot 升级到春 Boot 3.1打破了我的otel出口商

b4qexyjb  于 2023-06-22  发布在  Spring
关注(0)|答案(1)|浏览(113)

从Sping Boot 2.7.10(使用sleuth)升级到3.1(测微仪跟踪)后,我更新了我的otel exporter配置
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
  • 测微仪跟踪:1.1
  • opentelemetry-exporter-otlp:1.26.0
  • 克里思:2.1
jyztefdp

jyztefdp1#

Sping Boot 3.1 OtlpAutoConfiguration使用OtlpHttpSpanExporter,因此我们需要使用以下内容覆盖配置:

@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();
  }
}

相关问题