Kibana version: 8.11.1
Elasticsearch version: 8.11.1
APM Server version: 8.11.1
APM Agent language and version: opentelemetry-javaagent.jar 1.32.0
Browser version: not relevant
Original install method (e.g. download page, yum, deb, from source, etc.) and version: Elastic Cloud
Fresh install or upgraded from other version? fresh
Is there anything special in your setup? No, I'm using the default setup
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
I'm trying to instrument my application with the opentelemetry-javaagent.jar
agent and send the traces and metrics directly to the APM Server (without OpenTelemetry Collector in the middle), but I'm always facing the following error in the logs:
[otel.javaagent 2023-11-22 18:52:12:134 +0200] [OkHttp https://xxxx.apm.eu-central-1.aws.cloud.es.io/...] WARN io.opentelemetry.exporter.internal.grpc.GrpcExporter - Failed to export metrics. Server responded with gRPC status code 2.
Error message: stream was reset: PROTOCOL_ERROR
[otel.javaagent 2023-11-22 18:52:12:688 +0200] [OkHttp https://xxxx.apm.eu-central-1.aws.cloud.es.io/...] WARN io.opentelemetry.exporter.internal.grpc.GrpcExporter - Failed to export logs. Server responded with gRPC status code 2. Err
or message: stream was reset: PROTOCOL_ERROR
At first I was trying to run this setup with the Elastic Stack, running locally using Docker. Then I signed up for a free trial of Elastic Cloud to rule out any configuration errors I could have made with my Docker setup.
Then to rule out problems with my application I checked out the opentelemetry-java-examples
.
The result is always the same - the opentelemetry-javaagent
cannot connect to the APM Server with the same error.
Steps to reproduce:
- Setup Elastic APM Server (either with Elastic Cloud or using Docker, following this guide: Getting started with the Elastic Stack and Docker Compose: Part 2 | Elastic Blog)
- Checkout the OpenTelemetry
javaagent
example, from OpenTelemetry's official GitHub repo: https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/javaagent
Alternatively use any Java application. - Configure the OpenTelemetry Java Agent, as described in
{elastic_url}/app/home#/tutorial/apm
, which includes the following environment variables:
OTEL_EXPORTER_OTLP_ENDPOINT: <apm_server_endpoint>
OTEL_EXPORTER_OTLP_HEADERS: "Authorization=Bearer <secret_token>"
OTEL_METRICS_EXPORTER: otlp
OTEL_LOGS_EXPORTER: otlp
OTEL_RESOURCE_ATTRIBUTES: service.name=<app-name>,service.version=<app-version>,deployment.environment=production
- Download the latest
opentelemetry-javaagent.jar
from https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar - Run start the Java application with
-javaagent:path/to/opentelemetry-javaagent.jar
Notes:
- I've tested this with Java 11 and Java 17 on both Windows and MacOS
- Setting explicitly
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
, does not solve the issue - Setting
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
leads to the following error:
[otel.javaagent 2023-11-22 19:43:26:160 +0200] [OkHttp https://xxxx.apm.eu-central-1.aws.cloud.es.io/...] ERROR io.opentelemetry.exporter.internal.http.HttpExporter - Failed to export logs. The request could not be executed. Full erro
r message: stream was reset: PROTOCOL_ERROR
okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:148)
at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:97)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:110)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:93)
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 okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Suppressed: okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
... 18 more
Suppressed: okhttp3.internal.http2.StreamResetException: stream was reset: REFUSED_STREAM
... 18 more
Suppressed: okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
... 18 more