Skip to content

census: expose client interceptors #12050

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

AgraVator
Copy link
Contributor

@AgraVator AgraVator commented May 6, 2025

@AgraVator AgraVator marked this pull request as ready for review May 13, 2025 04:18
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving, but do consider the other API I mention in a comment, and whether we want to do that instead.

/**
* Returns a {@link ClientInterceptor} with default tracing implementation.
*/
public static ClientInterceptor newClientTracingInterceptor() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing all the statics is making me see why to more closely mirror GrpcOpenTelemetry. This could be fine as-is, because we don't care about it too much, but there do seem to be advantages in the GrpcOpenTelemetry API in clarity and letting us add options when needed.

If we had only configureServerBuilder() and configureChannelBuilder() on GrpcCensus and a builder to enable/disable stats/tracing, then gRPC could continue choosing the interceptor/tracer order and it would make configuring both OpenTelementry and OpenCensus more obvious.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@AgraVator AgraVator force-pushed the expose-census-apis branch from 30404f4 to 1ea671c Compare June 23, 2025 15:41
/**
* Creates a new builder for {@link GrpcCensus}.
*/
public static GrpcCensusBuilder builder() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use newBuilder() in Attributes, LoadBalancer, NameResolver, MethodDescriptor, tls credentials, etc. We don't have any public API that uses builder().

/**
* Builder for {@link GrpcCensus}.
*/
public static final class GrpcCensusBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name this class "Builder".

* Builds a new {@link GrpcCensus}.
*/
public GrpcCensus build() {
return new GrpcCensus(statsEnabled, tracingEnabled);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI: It doesn't matter in this case because there are few arguments, but I'll note that it scales better to pass this to the constructor.

* <p>GrpcCensus uses {@link io.opencensus.api.OpenCensus} APIs for instrumentation.
*
*/
public final class GrpcCensus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ExperimentalApi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a separate issue for the experimental API, as it will remain open after this PR is closed. #12178 will automatically be closed when this PR is closed.

/**
* Returns a {@link ClientInterceptor} with default stats implementation.
*/
public static ClientInterceptor newClientStatsInterceptor() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These static helpers need to become private or inlined into the configure methods.

@AgraVator AgraVator requested a review from ejona86 June 24, 2025 08:06
* <p>GrpcCensus uses {@link io.opencensus.api.OpenCensus} APIs for instrumentation.
*
*/
public final class GrpcCensus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a separate issue for the experimental API, as it will remain open after this PR is closed. #12178 will automatically be closed when this PR is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants