Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot: Error when configuring OTLP exporter in application.properties #10943

Closed
joaopgrassi opened this issue Mar 23, 2024 · 11 comments · Fixed by open-telemetry/opentelemetry.io#4258
Assignees
Labels
bug Something isn't working

Comments

@joaopgrassi
Copy link
Member

joaopgrassi commented Mar 23, 2024

Describe the bug

I generated a Spring Boot app from start.spring.io, and followed the steps on the website to add the OTel dependencies (gradle) https://opentelemetry.io/docs/languages/java/automatic/spring-boot/#opentelemetry-spring-boot-starter

I then saw we can use the same SDK configuration inside application.properties. So I added:

otel.service.name=java.springboot.api
otel.exporter.otlp.endpoint=http://my-collector:4317

And then when I start the application, I get a lot of errors such as:

java.io.IOException: unexpected end of stream on http://my-collector:4317/...
	at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:210) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:110) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:93) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.12.0.jar:na]
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517) ~[okhttp-4.12.0.jar:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
	Suppressed: java.io.IOException: unexpected end of stream on http://localhost:4317/...
		... 17 common frames omitted
	Caused by: java.io.EOFException: \n not found: limit=15 content=000006040000000000000500004000…

But when I configure the OTLP exporter endpoint like this:

spring.otel.exporter.otlp.endpoint=http://my-collector:4317

It works, and I get the spans in my collector.

Funny thing, is that otel.service.name works. If I change that to spring.otel.service.name then I don't have the service name on the resource.

Steps to reproduce

otel.service.name=java.springboot.api
otel.exporter.otlp.endpoint=http://localhost:4317
  • Run the app and see the errors (and no spans in the collector)

Expected behavior

The configuration works with the snippets from the OTel website

Actual behavior

No spans arriving when I use the configuration from the website instructions

Javaagent or library instrumentation version

opentelemetry-bom:1.36.0
opentelemetry-instrumentation-bom-alpha:2.2.0-alpha

Environment

JDK: eclipse-temurin:21-jdk
OS: Linux

Additional context

No response

@joaopgrassi joaopgrassi added bug Something isn't working needs triage New issue that requires triage labels Mar 23, 2024
@laurit
Copy link
Contributor

laurit commented Mar 24, 2024

Probably fails because the default otlp protocol is http/protobuf but you are sending to grpc endpoint (port 4317 is the default port for grpc, 4318 for http/protobuf). spring.otel.exporter.otlp.endpoint works because it is an unrecognized property and the default http/protobuf endpoint is used.

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Mar 24, 2024
@joaopgrassi
Copy link
Member Author

joaopgrassi commented Mar 24, 2024

Are you sure? Because here: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#otlp-exporter-span-metric-and-log-exporters otel.exporter.otlp.protocol the default is grpc. 🤔

Edit: That was it, you are right @laurit. I guess the the docs here need to be updated then :

The transport protocol to use on OTLP trace, metric, and log requests. Options include grpc and http/protobuf. Default is grpc.

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Mar 24, 2024
@laurit
Copy link
Contributor

laurit commented Mar 24, 2024

I guess the the docs here need to be updated

The referenced documentation is correct, for opentelemetry-java the default is grpc while opentelemetry-java-instrumentation defaults to http/protobuf. In opentelemetry-java-instrumentation the default was changed from grpc to http/protobuf with the 2.0 release. opentelemetry-java is still 1.x and the default there can't be changed without bumping the major version because it is a breaking change.

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Mar 24, 2024
@steverao steverao removed the needs triage New issue that requires triage label Mar 25, 2024
@joaopgrassi
Copy link
Member Author

Hum, I understand what you mean, but I don't think the documentation is right. My flow was:

  1. Go to OTel website to learn about OTel and Spring boot
  2. Then I went to Configuration to learn how to configure the OTLP Exporter URI
  3. The website then says:

The OpenTelemetry Starter supports all the SDK Autoconfiguration (since 2.2.0). You can set properties in the application.properties or the application.yaml file, or use environment variables.

  1. I navigate to SDK Autoconfiguration
  2. There I click on OTLP exporter (span, metric, and log exporters)
  3. I arrive at https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#otlp-exporter-span-metric-and-log-exporters, which tells me for otel.exporter.otlp.protocol grpc is the default.

I think the instructions then need to be modified to alert about the changes in instrumentation 2.0. I couldn't find this anywhere :(.

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Mar 26, 2024
@zeitlinger
Copy link
Member

That's right - I think this note got lost.

@laurit
Copy link
Contributor

laurit commented Apr 18, 2024

@zeitlinger can this issue be closed?

@zeitlinger
Copy link
Member

Yes, the docs have been updated here: https://opentelemetry.io/docs/languages/java/automatic/configuration/

@perfumescent
Copy link

thanks guys, the doc is a little bit confusing. I've checked for multiple times and still considered java agent jar as using default grpc.

@zeitlinger
Copy link
Member

thanks guys, the doc is a little bit confusing. I've checked for multiple times and still considered java agent jar as using default grpc.

can you point out what caused (which page) caused the confusion?

@perfumescent
Copy link

thanks guys, the doc is a little bit confusing. I've checked for multiple times and still considered java agent jar as using default grpc.

can you point out what caused (which page) caused the confusion?

OK, it's a kind of long road.

I started from multiple APM platforms and thus found opentelemetry. All of their docs mentioned configs like
-Dotel.exporter.otlp.endpoint=http://localhost:4317 -Dotel.exporter.otlp.headers. But I failed to run it with java program.

So I directly went for this page https://opentelemetry.io/docs/zero-code/java/agent/configuration/ as it is labeled as Java Agent.
However I couldnt find anything like otel.exporter.otlp config specification in this zero-code/java/agent/configuration unit. This is confusing.

Then I found all things with otel.exporter.otlp at https://opentelemetry.io/docs/languages/java/configuration/. I felt finally released and successfully confirmed that i was surely using the default protocol grpc.
image

This is confusing because java agent does not share the same config with java sdk while there is no noticeable specification on java agent page.

Is it clearly described?

@zeitlinger
Copy link
Member

Yes, this is great feedback for our project to improve the docs: open-telemetry/opentelemetry.io#4881

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants