-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
30404f4
to
1ea671c
Compare
/** | ||
* Creates a new builder for {@link GrpcCensus}. | ||
*/ | ||
public static GrpcCensusBuilder builder() { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ExperimentalApi
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
* <p>GrpcCensus uses {@link io.opencensus.api.OpenCensus} APIs for instrumentation. | ||
* | ||
*/ | ||
public final class GrpcCensus { |
There was a problem hiding this comment.
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.
Helps resolve https://b.corp.google.com/issues/391196954