census-instrumentation / opencensus-java

A stats collection and distributed tracing framework
https://opencensus.io
Apache License 2.0
672 stars 201 forks source link

gRpc client stats are not populated, additional configuration required #2080

Open iggyzap opened 2 years ago

iggyzap commented 2 years ago

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

    <properties>
        <io.grpc.version>1.35.0</io.grpc.version>
        <java.version>11</java.version>
        <opencensus.version>0.28.3</opencensus.version>
    </properties>

What JVM are you using (java -version)?

openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+11-alpine-r0)
OpenJDK 64-Bit Server VM (build 11.0.9+11-alpine-r0, mixed mode)

What did you do?

If possible, provide a recipe for reproducing the error.

  1. Configure opencensus instrumentation as described here: a. https://opencensus.io/guides/grpc/java/#instrumenting-the-client b. https://opencensus.io/zpages/java/#1
  2. When app starts and does few grpc exchanges, hit prometheus endpoint
  3. Observe only help for metrics
  4. Hit zPages endpoing
  5. Observe empty page

What did you expect to see?

Some stats related to invoked grpc methods

What did you see instead?

Just helptext for possible stats

Additional context

To enable stats following dependency needs to be included:

           <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-census</artifactId>
            <version>${io.grpc.version}</version>
        </dependency>

Also following code snipped needs to be added for gRpc stats to be gathered, when configuring managed channel

           ManagedChannelBuilder<?> builder = ManagedChannelBuilder
                .forAddress(serverUrl, port)
                .keepAliveTime(keepAliveMinutes, TimeUnit.MINUTES)

                .intercept(InternalCensusStatsAccessor.getClientInterceptor(true, true, true));
           return builder.build().

Even with changes from above, zPages still do not contain information about grpc invocations.