Skip to content

feat: Set sampledToLocalTracing flag to true for all gRPC MethodDescriptors #3874

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

Merged
merged 13 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.api.generator.engine.ast.Expr;
import com.google.api.generator.engine.ast.ExprStatement;
import com.google.api.generator.engine.ast.MethodInvocationExpr;
import com.google.api.generator.engine.ast.PrimitiveValue;
import com.google.api.generator.engine.ast.ScopeNode;
import com.google.api.generator.engine.ast.Statement;
import com.google.api.generator.engine.ast.StringObjectValue;
Expand Down Expand Up @@ -140,6 +141,16 @@ protected Statement createMethodDescriptorVariableDecl(
.apply("setResponseMarshaller", protoUtilsMarshallerFn.apply(methodInvocationArg))
.apply(methodDescriptorMaker);

// The sampledToLocalTracing flag is set to true for all gRPC MethodDescriptors in GAPICs
// This flag enables captures for specific method names to help provide more detailed metrics
methodDescriptorMaker =
methodMakerFn
.apply(
"setSampledToLocalTracing",
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("true").build()))
.apply(methodDescriptorMaker);

methodDescriptorMaker =
MethodInvocationExpr.builder()
.setMethodName("build")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class GrpcAutoPopulateFieldTestingStub extends AutoPopulateFieldTestingSt
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<
Expand All @@ -57,6 +58,7 @@ public class GrpcAutoPopulateFieldTestingStub extends AutoPopulateFieldTestingSt
ProtoUtils.marshaller(AutoPopulateFieldTestingExpandRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<
Expand All @@ -72,6 +74,7 @@ public class GrpcAutoPopulateFieldTestingStub extends AutoPopulateFieldTestingSt
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<
Expand All @@ -87,6 +90,7 @@ public class GrpcAutoPopulateFieldTestingStub extends AutoPopulateFieldTestingSt
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(AutoPopulateFieldTestingEchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class GrpcJobServiceStub extends JobServiceStub {
.setRequestMarshaller(
ProtoUtils.marshaller(JobProto.DeleteJobRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<JobProto.ListJobsRequest, JobProto.JobList>
Expand All @@ -45,6 +46,7 @@ public class GrpcJobServiceStub extends JobServiceStub {
.setRequestMarshaller(
ProtoUtils.marshaller(JobProto.ListJobsRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(JobProto.JobList.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<JobProto.DeleteJobRequest, Empty> deleteJobCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class GrpcCallableNameTypeServiceStub extends CallableNameTypeServiceStub
.setRequestMarshaller(
ProtoUtils.marshaller(GetApiOperationRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ApiOperation.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<GetApiOperationRequest, ApiOperation>
Expand All @@ -43,6 +44,7 @@ public class GrpcCallableNameTypeServiceStub extends CallableNameTypeServiceStub
.setRequestMarshaller(
ProtoUtils.marshaller(GetApiOperationRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ApiOperation.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<GetApiOperationRequest, ApiOperation> getApiOperationCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GrpcDeprecatedServiceStub extends DeprecatedServiceStub {
.setFullMethodName("google.testdata.v1.DeprecatedService/FastFibonacci")
.setRequestMarshaller(ProtoUtils.marshaller(FibonacciRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<FibonacciRequest, Empty> slowFibonacciMethodDescriptor =
Expand All @@ -40,6 +41,7 @@ public class GrpcDeprecatedServiceStub extends DeprecatedServiceStub {
.setFullMethodName("google.testdata.v1.DeprecatedService/SlowFibonacci")
.setRequestMarshaller(ProtoUtils.marshaller(FibonacciRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<FibonacciRequest, Empty> fastFibonacciCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/Echo")
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<ExpandRequest, EchoResponse> expandMethodDescriptor =
Expand All @@ -57,6 +58,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/Expand")
.setRequestMarshaller(ProtoUtils.marshaller(ExpandRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<EchoRequest, EchoResponse> collectMethodDescriptor =
Expand All @@ -65,6 +67,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/Collect")
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<EchoRequest, EchoResponse> chatMethodDescriptor =
Expand All @@ -73,6 +76,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/Chat")
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<EchoRequest, EchoResponse> chatAgainMethodDescriptor =
Expand All @@ -81,6 +85,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/ChatAgain")
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<PagedExpandRequest, PagedExpandResponse>
Expand All @@ -91,6 +96,7 @@ public class GrpcEchoStub extends EchoStub {
.setRequestMarshaller(ProtoUtils.marshaller(PagedExpandRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(PagedExpandResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<PagedExpandRequest, PagedExpandResponse>
Expand All @@ -101,6 +107,7 @@ public class GrpcEchoStub extends EchoStub {
.setRequestMarshaller(ProtoUtils.marshaller(PagedExpandRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(PagedExpandResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<WaitRequest, Operation> waitMethodDescriptor =
Expand All @@ -109,6 +116,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/Wait")
.setRequestMarshaller(ProtoUtils.marshaller(WaitRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<BlockRequest, BlockResponse> blockMethodDescriptor =
Expand All @@ -117,6 +125,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/Block")
.setRequestMarshaller(ProtoUtils.marshaller(BlockRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(BlockResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<EchoRequest, Object> collideNameMethodDescriptor =
Expand All @@ -125,6 +134,7 @@ public class GrpcEchoStub extends EchoStub {
.setFullMethodName("google.showcase.v1beta1.Echo/CollideName")
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Object.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<PagedExpandLegacyRequest, PagedExpandResponse>
Expand All @@ -136,6 +146,7 @@ public class GrpcEchoStub extends EchoStub {
ProtoUtils.marshaller(PagedExpandLegacyRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(PagedExpandResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<EchoRequest, EchoResponse> echoCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
.setFullMethodName("google.logging.v2.LoggingServiceV2/DeleteLog")
.setRequestMarshaller(ProtoUtils.marshaller(DeleteLogRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<WriteLogEntriesRequest, WriteLogEntriesResponse>
Expand All @@ -57,6 +58,7 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
ProtoUtils.marshaller(WriteLogEntriesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(WriteLogEntriesResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<ListLogEntriesRequest, ListLogEntriesResponse>
Expand All @@ -68,6 +70,7 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
ProtoUtils.marshaller(ListLogEntriesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListLogEntriesResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<
Expand All @@ -85,6 +88,7 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
.setResponseMarshaller(
ProtoUtils.marshaller(
ListMonitoredResourceDescriptorsResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<ListLogsRequest, ListLogsResponse>
Expand All @@ -94,6 +98,7 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
.setFullMethodName("google.logging.v2.LoggingServiceV2/ListLogs")
.setRequestMarshaller(ProtoUtils.marshaller(ListLogsRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListLogsResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<TailLogEntriesRequest, TailLogEntriesResponse>
Expand All @@ -105,6 +110,7 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
ProtoUtils.marshaller(TailLogEntriesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(TailLogEntriesResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<DeleteLogRequest, Empty> deleteLogCallable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class GrpcPublisherStub extends PublisherStub {
.setFullMethodName("google.pubsub.v1.Publisher/CreateTopic")
.setRequestMarshaller(ProtoUtils.marshaller(Topic.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Topic.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<UpdateTopicRequest, Topic> updateTopicMethodDescriptor =
Expand All @@ -56,6 +57,7 @@ public class GrpcPublisherStub extends PublisherStub {
.setFullMethodName("google.pubsub.v1.Publisher/UpdateTopic")
.setRequestMarshaller(ProtoUtils.marshaller(UpdateTopicRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Topic.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<PublishRequest, PublishResponse> publishMethodDescriptor =
Expand All @@ -64,6 +66,7 @@ public class GrpcPublisherStub extends PublisherStub {
.setFullMethodName("google.pubsub.v1.Publisher/Publish")
.setRequestMarshaller(ProtoUtils.marshaller(PublishRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(PublishResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<GetTopicRequest, Topic> getTopicMethodDescriptor =
Expand All @@ -72,6 +75,7 @@ public class GrpcPublisherStub extends PublisherStub {
.setFullMethodName("google.pubsub.v1.Publisher/GetTopic")
.setRequestMarshaller(ProtoUtils.marshaller(GetTopicRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Topic.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<ListTopicsRequest, ListTopicsResponse>
Expand All @@ -81,6 +85,7 @@ public class GrpcPublisherStub extends PublisherStub {
.setFullMethodName("google.pubsub.v1.Publisher/ListTopics")
.setRequestMarshaller(ProtoUtils.marshaller(ListTopicsRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListTopicsResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<
Expand All @@ -94,6 +99,7 @@ public class GrpcPublisherStub extends PublisherStub {
ProtoUtils.marshaller(ListTopicSubscriptionsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListTopicSubscriptionsResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<ListTopicSnapshotsRequest, ListTopicSnapshotsResponse>
Expand All @@ -105,6 +111,7 @@ public class GrpcPublisherStub extends PublisherStub {
ProtoUtils.marshaller(ListTopicSnapshotsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListTopicSnapshotsResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<DeleteTopicRequest, Empty> deleteTopicMethodDescriptor =
Expand All @@ -113,6 +120,7 @@ public class GrpcPublisherStub extends PublisherStub {
.setFullMethodName("google.pubsub.v1.Publisher/DeleteTopic")
.setRequestMarshaller(ProtoUtils.marshaller(DeleteTopicRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private static final MethodDescriptor<DetachSubscriptionRequest, DetachSubscriptionResponse>
Expand All @@ -124,6 +132,7 @@ public class GrpcPublisherStub extends PublisherStub {
ProtoUtils.marshaller(DetachSubscriptionRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(DetachSubscriptionResponse.getDefaultInstance()))
.setSampledToLocalTracing(true)
.build();

private final UnaryCallable<Topic, Topic> createTopicCallable;
Expand Down
Loading
Loading