GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(o11y): Introduce `rpc.system.name` and `rpc.method` in gRPC by diegomarquezp · Pull Request #4121 · googleapis/sdk-platform-java
This repository was archived by the owner on Oct 29, 2026. It is now read-only.
Conversation
|
Summary of ChangesHello @diegomarquezp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces significant improvements to the observability framework by enriching tracing contexts with RPC system and method information. It refactors the tracing mechanism to be more flexible and less dependent on specific span naming conventions, allowing for better integration with standardized observability practices. The changes streamline how RPC details are captured and propagated through the tracing system, enhancing the clarity and utility of generated traces. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces a significant and beneficial refactoring to the tracing infrastructure. By replacing the explicit SpanName with a more structured ApiTracerContext carried by ApiTracerFactory, the code becomes more maintainable and extensible. The introduction of rpc.system.name and rpc.method attributes aligns with modern observability practices.
However, there are a couple of points that need attention:
Missing Tests (Critical): The PR adds new logic (e.g., in ApiTracerContext) and refactors existing components, but it lacks corresponding unit tests. The repository's contribution guidelines (line 148: Testing: All new logic should be accompanied by tests.) are not being met. Please add tests for the new functionality, especially for the parsing logic in ApiTracerContext.fromGrpcMethodName and ApiTracerContext.fromHttpJsonMethodName, and ensure existing tests are updated to reflect the API changes.
Robustness: There's a potential for a NullPointerException in SpanTracerFactory which can be addressed with a defensive check.
Overall, this is a good direction, but the lack of tests is a critical issue that must be addressed before merging.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
b32f09a to
e5b927a
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
/gemini review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces rpc.system.name and rpc.method span attributes for gRPC tracing, which is a great enhancement for observability. The implementation is well-structured, refactoring tracing context creation into a new ApiTracerContext class and adding new overloads to the Traced*Callable classes and ApiTracerFactory. The test coverage is excellent, with new parameterized tests to handle both old and new code paths, and an integration test to verify the new attributes are correctly added to spans. I have a couple of minor suggestions to improve documentation and code consistency.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…ilityAttributes.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…https://github.com/googleapis/sdk-platform-java into observability/tracing-attr/rpc.method-and-rpc.system
| * @return a new {@link SpanName} with the parsed client name and method name | ||
| */ | ||
| public static SpanName of(ApiTracerContext apiTracerContext) { | ||
| Preconditions.checkState(apiTracerContext.fullMethodName() != null, "rpcMethod must be set"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think fullMethodName() is nullable? Also can we only pass a String to this method?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think fullMethodName() is nullable?
I made it @Nullable considering the client-level vs method-def-level contexts we can have. ClientContext will not populate fullMethodName().
Also can we only pass a String to this method?
The problem with SpanName.of(apiTracerContext.getFullMethodName()) is that the callable factories cannot access the package-private method.
Lines 224 to 234 in cee771f
| @InternalApi("Visible for testing") | |
| static SpanName getSpanName(@Nonnull ApiMethodDescriptor<?, ?> methodDescriptor) { | |
| ApiTracerContext apiTracerContext = | |
| ApiTracerContext.newBuilder() | |
| .setFullMethodName(methodDescriptor.getFullMethodName()) | |
| .setTransport(ApiTracerContext.Transport.HTTP) | |
| .setLibraryMetadata(LibraryMetadata.empty()) | |
| .build(); | |
| return SpanName.of(apiTracerContext); | |
| } | |
| } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I made it @nullable considering the client-level vs method-def-level contexts we can have. ClientContext will not populate fullMethodName()
I see, makes sense. This might be another data point that it's time to create a ClientTracerContext that only contains client level tracer info. And we can merge it with method/request level before we create a request level tracer. I feel we have a lot of nullable fields in ApiTracerContext only because we don't have the info initially. But we can do it in another PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll follow up with separating the contexts.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| this.innerCallable = innerCallable; | ||
| this.tracerFactory = tracerFactory; | ||
| this.apiTracerContext = apiTracerContext; | ||
| this.spanName = null; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can create a spanName from ApiTracerContext now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
But we wouldn't use it if we have the context, right?
AFAIU we are trying to provide logic that only handles a context object as the SoT for SpanName. That's why we made this change in ApiTracer:
sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedUnaryCallable.java
Lines 84 to 88 in cee771f
| if (apiTracerContext != null) { | |
| tracer = tracerFactory.newTracer(context.getTracer(), apiTracerContext, OperationType.Unary); | |
| } else { | |
| tracer = tracerFactory.newTracer(context.getTracer(), spanName, OperationType.Unary); | |
| } |
sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracerFactory.java
Lines 72 to 76 in cee771f
| default ApiTracer newTracer( | |
| ApiTracer parent, ApiTracerContext tracerContext, OperationType operationType) { | |
| SpanName spanName = SpanName.of(tracerContext); | |
| return newTracer(parent, spanName, operationType); | |
| } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Even if we don't use it, I think it's safer to populate it instead of making it nullable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, done.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| private final UnaryCallable<RequestT, ResponseT> innerCallable; | ||
| private final ApiTracerFactory tracerFactory; | ||
| private final SpanName spanName; | ||
| @Nullable private final SpanName spanName; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep this spanName not nullable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll do it once we confirm my question in #4121 (comment)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
See answers below. Ideally we probably want to remove SpanName as a field, and only use ApiTracerContext as the source of truth. But it can not be done until we migrated all Callables to use ApiTracerContext.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
until we migrated all Callables to use ApiTracerContext
I thought the problem was with other classes that create the callables, such as GrpcCallableFactory. Are there usages of Traced*Callable in downstream libraries?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * @param tracerContext the method-definition-specific tracer context | ||
| * @param operationType the type of operation that the tracer will trace | ||
| */ | ||
| default ApiTracer newTracer( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The downstream failure in bigtable is legit. One possible solution is to move OperationType to ApiTracerContext
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@diegomarquezp Thanks for adding a new overloaded method! We need to remove this method as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Replace L85 with this method impl. and delete this method.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Regarding Bigtable: Removed method.
Regarding Spanner: The traced callables were not setting apiTracerContext.setOperationType and a null check in the Spanner tracer was failing. I was surprised our tests didn't catch it, so I added a null check in MetricsTracerFactory and OpencensusTracerFactory.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-attr/rpc.method-and-rpc.system
| this.tracerFactory = Preconditions.checkNotNull(tracerFactory, "tracerFactory can't be null"); | ||
| this.apiTracerContext = | ||
| Preconditions.checkNotNull(apiTracerContext, "apiTracerContext can't be null").toBuilder() | ||
| .setOperationType(OperationType.ClientStreaming) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This should be ServerStreaming
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we also add unit tests for these default OperationType?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch. Done.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we also add unit tests for these default OperationType?
Done in 6b67410
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
🤖 I have created a release *beep* *boop* --- <details><summary>2.68.0</summary> ## [2.68.0](v2.67.0...v2.68.0) (2026-03-17) ### Features * Add client request duration metric. ([#4132](#4132)) ([6a76397](6a76397)) * Add more attributes to golden signals metrics. ([#4135](#4135)) ([59d0624](59d0624)) * **gax-httpjson:** add HttpJsonErrorParser utility ([#4137](#4137)) ([a1b7565](a1b7565)) * **generator:** add extra allowed modules that will not be removed from the monorepo if they are present ([#4124](#4124)) ([774fe6e](774fe6e)) * **o11y:** introduce `gcp.client.repo` and `gcp.client.artifact` attributes ([#4120](#4120)) ([105f644](105f644)) * **o11y:** Introduce `rpc.system.name` and `rpc.method` in gRPC ([#4121](#4121)) ([7ab6d2e](7ab6d2e)) * **o11y:** introduce server.port attribute ([#4128](#4128)) ([56aa343](56aa343)) ### Bug Fixes * add null checks for ApiTracerFactory in ClientContext ([#4122](#4122)) ([4b3dbe2](4b3dbe2)) * Decrease log level for directpath warnings outside GCE ([#4139](#4139)) ([c9651e7](c9651e7)) * **gax-grpc:** add pick_first fallback to direct path service config ([#4143](#4143)) ([b150fe9](b150fe9)) * Populate method level attributes in metrics recording ([#4149](#4149)) ([7b7e6c9](7b7e6c9)) * suppress warnings in generated projects for non-idiomatic durations ([#4119](#4119)) ([4206e6e](4206e6e)) * Use ServiceName + MethodName as the regex for Otel ([#2543](#2543)) ([b9ae73f](b9ae73f)) ### Documentation * **hermetic_build:** fix config field name in readme ([#4130](#4130)) ([a0c8f67](a0c8f67)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>2.68.0</summary> ## [2.68.0](googleapis/sdk-platform-java@v2.67.0...v2.68.0) (2026-03-17) ### Features * Add client request duration metric. ([#4132](googleapis/sdk-platform-java#4132)) ([487650e](googleapis/sdk-platform-java@487650e)) * Add more attributes to golden signals metrics. ([#4135](googleapis/sdk-platform-java#4135)) ([bc82dcb](googleapis/sdk-platform-java@bc82dcb)) * **gax-httpjson:** add HttpJsonErrorParser utility ([#4137](googleapis/sdk-platform-java#4137)) ([6fe2446](googleapis/sdk-platform-java@6fe2446)) * **generator:** add extra allowed modules that will not be removed from the monorepo if they are present ([#4124](googleapis/sdk-platform-java#4124)) ([6a440da](googleapis/sdk-platform-java@6a440da)) * **o11y:** introduce `gcp.client.repo` and `gcp.client.artifact` attributes ([#4120](googleapis/sdk-platform-java#4120)) ([4954de5](googleapis/sdk-platform-java@4954de5)) * **o11y:** Introduce `rpc.system.name` and `rpc.method` in gRPC ([#4121](googleapis/sdk-platform-java#4121)) ([3593c30](googleapis/sdk-platform-java@3593c30)) * **o11y:** introduce server.port attribute ([#4128](googleapis/sdk-platform-java#4128)) ([1b10e02](googleapis/sdk-platform-java@1b10e02)) ### Bug Fixes * add null checks for ApiTracerFactory in ClientContext ([#4122](googleapis/sdk-platform-java#4122)) ([ded1922](googleapis/sdk-platform-java@ded1922)) * Decrease log level for directpath warnings outside GCE ([#4139](googleapis/sdk-platform-java#4139)) ([5151f34](googleapis/sdk-platform-java@5151f34)) * **gax-grpc:** add pick_first fallback to direct path service config ([#4143](googleapis/sdk-platform-java#4143)) ([4934ad8](googleapis/sdk-platform-java@4934ad8)) * Populate method level attributes in metrics recording ([#4149](googleapis/sdk-platform-java#4149)) ([69aabf8](googleapis/sdk-platform-java@69aabf8)) * suppress warnings in generated projects for non-idiomatic durations ([#4119](googleapis/sdk-platform-java#4119)) ([8a0c565](googleapis/sdk-platform-java@8a0c565)) * Use ServiceName + MethodName as the regex for Otel ([#2543](googleapis/sdk-platform-java#2543)) ([8196b8f](googleapis/sdk-platform-java@8196b8f)) ### Documentation * **hermetic_build:** fix config field name in readme ([#4130](googleapis/sdk-platform-java#4130)) ([0d98c37](googleapis/sdk-platform-java@0d98c37)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.