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

Exception with OtlpGrpcSpanExporter and latest grpc #5907

Closed
croudet opened this issue Oct 11, 2023 · 6 comments
Closed

Exception with OtlpGrpcSpanExporter and latest grpc #5907

croudet opened this issue Oct 11, 2023 · 6 comments
Labels
Bug Something isn't working

Comments

@croudet
Copy link

croudet commented Oct 11, 2023

Describe the bug
Got an exception when trying to build and OtlpGrpcSpanExporter not using default okhttp exporter but opentelemetry-exporter-sender-grpc-managed-channel

Exception in thread "main" java.lang.NullPointerException: channel
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:921)
	at io.grpc.ClientInterceptors.intercept(ClientInterceptors.java:87)
	at io.grpc.ClientInterceptors.intercept(ClientInterceptors.java:74)
	at io.opentelemetry.exporter.sender.grpc.managedchannel.internal.UpstreamGrpcSenderProvider.createSender(UpstreamGrpcSenderProvider.java:59)
	at io.opentelemetry.exporter.internal.grpc.GrpcExporterBuilder.build(GrpcExporterBuilder.java:158)
	at io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder.build(OtlpGrpcSpanExporterBuilder.java:189)

Steps to reproduce

public static void main(String... args) {
        OtlpGrpcSpanExporter.builder()
                .setEndpoint("https://collector-service:4317")
                .build();

What did you expect to see?
No Exception.

What did you see instead?
An exception because channel is null and io.grpc.ClientInterceptors.intercept checks that.

What version and what artifacts are you using?
grpc-java: 1.58.0

<dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-exporter-otlp</artifactId>
      <version>1.31.0</version>
      <exclusions>
        <exclusion>
          <groupId>io.opentelemetry</groupId>
          <artifactId>opentelemetry-exporter-sender-okhttp</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.squareup.okhttp3</groupId>
          <artifactId>okhttp</artifactId>
        </exclusion>
      </exclusions>
 </dependency>
 <dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-exporter-sender-grpc-managed-channel</artifactId>
      <version>1.31.0</version>
 </dependency>

Environment
Compiler: OpenJDK Runtime Environment Temurin-17.0.8+7 (build 17.0.8+7)
OS: Windows

@croudet croudet added the Bug Something isn't working label Oct 11, 2023
@laurit
Copy link
Contributor

laurit commented Oct 12, 2023

As far as I understand you should supply the channel instead of the endpoint like it is done in

try (Closeable exporter = OtlpGrpcSpanExporter.builder().setChannel(channel).build()) {
to use the upstream grpc implementation. Did this worke in a previous version?

@croudet
Copy link
Author

croudet commented Oct 12, 2023

Yes, but setChannel is deprecated, I wonder if there was another way to initialize it.

@jack-berg
Copy link
Member

Yes @laurit is correct.

#4531 describes a use case where setEndpoint is insufficient and requests that we do not deprecate setChannel. In general, we want to encourage use of the OkHttp exporter and expand the capabilities of it where missing. I'm going to close this in favor of #4531, but it would be helpful if you could describe your use case for using opentelemetry-exporter-sender-grpc-managed-channel on that issue.

@croudet
Copy link
Author

croudet commented Oct 12, 2023

it is just that okhttp brings kotlin dependencies, and in the project I plan to use it, we already have grpc-java.

@jack-berg
Copy link
Member

If you're on java 11+, consider using opentelemetry-exporter-sender-jdk. It only supports OtlpHttp{Signal}Exporters (i.e. the http/protobuf) version of the protocol), but uses the built in JDK HttpClient and has zero transitive dependencies.

@fax4ever
Copy link
Contributor

fax4ever commented Nov 2, 2023

@jack-berg is there a way to setChannel using autoconfigure? thanks

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

No branches or pull requests

4 participants