GoogleCloudPlatform / opentelemetry-operations-java

Apache License 2.0
71 stars 38 forks source link

Receiver class io.grpc.netty.shaded.io.grpc.netty.NettyClientTransport does not define or inherit an implementation of the resolved method 'abstract io.grpc.internal.ClientStream newStream(io.grpc.MethodDescriptor, io.grpc.Metadata, io.grpc.CallOptions, io.grpc.ClientStreamTracer[])' of interface io.grpc.internal.ClientTransport. #184

Closed ViliusS closed 1 year ago

ViliusS commented 1 year ago

Exporter-trace is not compatible with modern 3rd party frameworks/libraries. For example, when using it with https://mvnrepository.com/artifact/org.axonframework/axon-server-connector/4.6.2 we see such error:

Caused by: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Credentials should use fail() instead of throwing exceptions at io.grpc.Status.asRuntimeException(Status.java:535) ... 10 common frames omitted Caused by: java.lang.AbstractMethodError: Receiver class io.grpc.netty.shaded.io.grpc.netty.NettyClientTransport does not define or inherit an implementation of the resolved method 'abstract io.grpc.internal.ClientStream newStream(io.grpc.MethodDescriptor, io.grpc.Metadata, io.grpc.CallOptions, io.grpc.ClientStreamTracer[])' of interface io.grpc.internal.ClientTransport.

This is because latest exporter-trace depends on a very old google-cloud-trace library which depends on grpc 1.39, a very old version which is not forward compatible with 1.40 or newer versions. Most frameworks these days depend on grpc 1.46-1.50. See similar issue here https://github.com/googleapis/java-pubsub/issues/903

Using Google Cloud libraries BOM resolves google-cloud-trace to newer version and this help with an issue, however I believe this is just a workaround. exporter-trace needs to update cloud libraries in the build itself.

dashpole commented 1 year ago

cc @jsuereth @psx95

Suggestion (to us): Bump the cloud trace version.

psx95 commented 1 year ago

Bumping the version to the latest ones is causing Issue #141 to resurface (which does not happen with the dependency versions used in current head)

The following versions were used/updated in the experiment -

googleCloudVersion = '2.9.4'.                                    // was 2.0.5
googleTraceVersion = '2.9.0'                                     // was 2.0.0
cloudMonitoringVersion = '3.10.0'                            // was 3.0.0
openTelemetryVersion = '1.22.0'                              // was 1.15.0
openTelemetryInstrumentationVersion = '1.22.0'   // was 1.14.0 
pubSubVersion = '1.123.1'                                         // was 1.111.2
...
com.google.cloud:google-cloud-core:${googleCloudVersion}"
com.google.cloud:google-cloud-trace:${googleTraceVersion}"
com.google.api.grpc:grpc-google-cloud-trace-v2:${googleTraceVersion}"
com.google.cloud:google-cloud-monitoring:${cloudMonitoringVersion}"
com.google.cloud:grpc-google-cloud-monitoring-v3:${cloudMonitoringVersion}"
com.google.cloud:google-cloud-pubsub:${pubSubVersion}"

// OTel dependency updates
io.opentelemetry:opentelemetry-api:${openTelemetryVersion}
io.opentelemetry:opentelemetry-context:${openTelemetryVersion}
io.opentelemetry:opentelemetry-sdk:${openTelemetryVersion}
io.opentelemetry:opentelemetry-sdk-common:${openTelemetryVersion}
io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:${openTelemetryVersion}
io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${openTelemetryVersion}-alpha
io.opentelemetry:opentelemetry-semconv:${openTelemetryVersion}-alpha
io.opentelemetry:opentelemetry-sdk-metrics:${openTelemetryVersion}
io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${openTelemetryVersion}-alpha
io.opentelemetry:opentelemetry-sdk-extension-resources:${openTelemetryVersion}

Opencensus-shim version was also updated to the latest one (1.22.0-alpha) in the test code for consistency.

psx95 commented 1 year ago

@ViliusS could you share some test code that can help reproduce this issue ?

ViliusS commented 1 year ago

Unfortunately no, not at the moment. Our microservice dependencies are pretty intertwined.

But I think you should be able to replicate this issue very easy. Just take any GCP exporter-trace example and add:

<dependency>
    <groupId>org.axonframework</groupId>
    <artifactId>axon-server-connector</artifactId>
    <version>4.6.3</version>
</dependency>

as a dependency. You probably don't need to use anything from Axon package in the code, just make sure GRPC coming from it, which I believe is version 1.50, overrides what is provided by exporter-trace in the classpath. I'm using Maven so it overrides these GRPC dependencies by default.

psx95 commented 1 year ago

Thanks for the information. I will try this out.

psx95 commented 1 year ago

NOTE: I was able to reproduce the issue when using com.google.cloud.opentelemetry:exporter-trace:0.23.0' (latest release on Maven).


To verify if the issue persists in the latest code: I built a shadowJar from the HEAD of the main branch by adding the following -

plugins {
    id 'java'
    id 'com.github.johnrengelman.shadow'
}

at the very beginning of exporters/trace/build.gradle and then running -

./gradlew shadowJar

from the root of the repository.

In my test application, I installed the built JAR as a local dependency and was successfully able to start the app (spring-boot application).

Here are the dependencies used in the test app (from pom.xml, just for information) -

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- tag::actuator[] -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!-- end::actuator[] -->

        <!-- tag::tests[] -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- end::tests[] -->

                <!-- v0.1.1-local does not exist on Maven, installed locally from JAR --> 
        <dependency>
            <groupId>com.google.cloud.opentelemetry</groupId>
            <artifactId>exporter-trace</artifactId>
            <version>0.1.1-local</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.axonframework/axon-server-connector -->
        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-server-connector</artifactId>
            <version>4.6.3</version>
        </dependency>

        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-metrics</artifactId>
            <version>1.22.0</version>
        </dependency>

        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-opencensus-shim</artifactId>
            <version>1.22.0-alpha</version>
        </dependency>

        <dependency>
            <groupId>io.opencensus</groupId>
            <artifactId>opencensus-api</artifactId>
            <version>0.31.0</version>
        </dependency>

    </dependencies>

@ViliusS Could you try this once and confirm if it's working for you ? If it does, we do have a bug for creating a release with the updated code and you can track that instead - #188

ViliusS commented 1 year ago

@psx95 just to understand, are you saying that the issue is probably fixed in HEAD, i.e. latest Maven release shows you GRPC error message, but using the steps above with HEAD code works without issues?

psx95 commented 1 year ago

Yes, that's what I found. But I would like you to try this once, just for verification.

ViliusS commented 1 year ago

I will try it in a few days. I'm not familiar with gradle though. If you can upload or attach generated JAR it would save me some time.

That's interesting nevertheless as I don't see any changes regarding dependencies in HEAD. Unless gradle always pulls latest GCP dependencies during build?

psx95 commented 1 year ago

Yes, that seemed a little odd to me as well.

No, gradle only auto-updates the dependencies if you do not specify the exact version. The gradle build files in this repo have the exact version specified.

exporter-trace-0.1.0-SNAPSHOT-all.jar.zip

Also, the error message I got was not exactly similar to the one posted above, but it was a NoClassDefFoundError for some gRPC classes.

psx95 commented 1 year ago

With #188 complete, we have an updated version of the library which should address this issue. Feel free to re-open if using the new version does not resolve this issue.

There might still be a known issue involving the use of opencensus-shim API - #141

Steps taken to reproduce this issue

                 <dependency>
            <groupId>com.google.cloud.opentelemetry</groupId>
            <artifactId>exporter-trace</artifactId>
            <version>0.24.0</version>
                 </dependency>

        <!-- https://mvnrepository.com/artifact/org.axonframework/axon-server-connector -->
        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-server-connector</artifactId>
            <version>4.6.3</version>
        </dependency>

Build system used - Maven