Java应用OpenTelemetry从1.42.1升级至1.44.x时遇导出错误
OpenTelemetry升级至1.44.1后Span导出失败问题
问题概述
将Spring Boot WebFlux应用的OpenTelemetry从1.42.1版本(原版本可正常上报指标)升级到1.44.1版本后,出现Span导出失败的问题,同时伴随两类报错。
报错信息
第一类报错:ProtocolException
Mar 07, 2025 3:27:11 AM io.opentelemetry.sdk.internal.ThrottlingLogger doLog SEVERE: Failed to export spans. The request could not be executed. Error message: expected 4136 bytes but received 4153 java.net.ProtocolException: expected 4136 bytes but received 4153 at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:219) at okio.RealBufferedSink.close(RealBufferedSink.kt:280) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:63) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at io.opentelemetry.exporter.sender.okhttp.internal.RetryInterceptor.intercept(RetryInterceptor.java:91) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583)
第二类报错:ArrayIndexOutOfBoundsException(间歇性出现)
SEVERE: Failed to export spans. The request could not be executed. Error message: canceled due to java.lang.ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128 java.io.IOException: canceled due to java.lang.ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128 at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:530) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583) Suppressed: java.lang.ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128 ... 3 more
相关依赖版本信息
Java => 21 Helm chart DD版本: 3.102.0 AWS上的DD Agent(通过Helm Chart配置): v7.63.2 org.springframework.boot => 3.4.3(WebFlux项目) mavenBom("io.opentelemetry:opentelemetry-bom:1.44.1") mavenBom("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.10.0") // Prometheus/指标相关 implementation "org.springframework.boot:spring-boot-starter-actuator:3.4.2" implementation "io.micrometer:micrometer-registry-prometheus" implementation 'io.micrometer:micrometer-registry-datadog' implementation 'io.micrometer:micrometer-registry-statsd:1.14.3' // OpenTelemetry相关 implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter") implementation("io.opentelemetry.contrib:opentelemetry-samplers:1.41.0-alpha") implementation("io.opentelemetry.instrumentation:opentelemetry-runtime-telemetry-java17:2.10.0-alpha")
OpenTelemetry配置信息
otel.traces.exporter=otlp otel.metrics.exporter=otlp otel.metric.export.interval=20000 otel.logs.exporter=none otel.exporter.otlp.protocol=grpc (我甚至尝试改用http/protobuf协议,但问题依旧) otel.exporter.otlp.endpoint=${OTEL_EXPORTER_OTLP_ENDPOINT:http://localhost:4317} otel.instrumentation.logback-appender.enabled=false
内容的提问来源于stack exchange,提问作者Ashok Kumar P S
相关产品推荐
相关产品推荐

