Skip to content

Conversation

@blakeli0
Copy link
Contributor

@blakeli0 blakeli0 commented Feb 9, 2026

No description provided.

@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Feb 9, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @blakeli0, 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 implements a proof-of-concept for application-centric metrics within GAX-Java, leveraging OpenTelemetry. The primary goal is to provide more detailed and standardized observability into client request durations and outcomes. This involves introducing a new metrics recorder and updating existing tracing components to use consistent attribute naming conventions, ensuring that critical operational data is captured and made available for monitoring and analysis.

Highlights

  • New App-Centric Metrics Recorder: Introduced AppCentricMetricsRecorder to enable OpenTelemetry-based application-centric metrics for GAX-Java, specifically recording gcp.client.request.duration.
  • Standardized Metric Attribute Keys: Standardized metric attribute keys for RPC method and status to rpc.method and grpc.status respectively, aligning with OpenTelemetry conventions.
  • Comprehensive Integration Tests: Added extensive integration tests in ITAppCentricMetrics to validate the new metrics recording functionality across various gRPC and HTTP/JSON scenarios, including successful operations, cancellations, failures, and retries, and verifying custom attributes.
Changelog
  • gax-java/gax/src/main/java/com/google/api/gax/tracing/AppCentricMetricsRecorder.java
    • Added a new class AppCentricMetricsRecorder that implements MetricsRecorder to record gcp.client.request.duration histogram metrics using OpenTelemetry.
    • Implemented a method to convert a map of string attributes to OpenTelemetry Attributes.
  • gax-java/gax/src/main/java/com/google/api/gax/tracing/MetricsTracer.java
    • Updated the METHOD_ATTRIBUTE constant from "method" to "rpc.method".
    • Updated the STATUS_ATTRIBUTE constant from "status" to "grpc.status".
  • java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITAppCentricMetrics.java
    • Added a new integration test suite ITAppCentricMetrics to verify the correct recording of app-centric metrics.
    • Included tests for successful gRPC and HTTP/JSON operations, cancelled operations, failed operations, and operations with retries.
    • Verified the presence and correctness of default and custom attributes in the recorded metrics.
    • Ensured proper method name recording when using GrpcOpenTelemetry.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an AppCentricMetricsRecorder as a proof-of-concept for app-centric metrics. It also updates some metric attribute names to align with OpenTelemetry conventions and adds a new integration test suite.

My review has identified a couple of issues:

  • There's a unit mismatch in AppCentricMetricsRecorder where latency in milliseconds is recorded for a metric with units of seconds.
  • The new integration test ITAppCentricMetrics seems to contain incorrect logic, as it appears to be testing for metrics produced by a different recorder (OpenTelemetryMetricsRecorder) and makes wrong assumptions about how AppCentricMetricsRecorder works.

Please see the detailed comments for suggestions on how to address these points.

* via {@link #verifyStatusAttribute(List, List)}. Finally, check that the status for each attempt
* is correct.
*/
class ITAppCentricMetrics {
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The test logic in this class appears to be based on OpenTelemetryMetricsRecorder rather than AppCentricMetricsRecorder, leading to incorrect assertions. AppCentricMetricsRecorder only records a single metric gcp.client.request.duration once per operation.

Specifically:

  1. verifyPointDataSum checks for metrics that are not produced (ShowcaseTest/operation_latency, ShowcaseTest/attempt_latency). It should be verifying gcp.client.request.duration.
  2. verifyStatusAttribute incorrectly assumes that a metric point is recorded for each attempt. It should verify only the single final status of the whole operation. For example, in testGrpc_multipleFailedAttempts_successfulOperation, only a single point with status OK will be recorded.
  3. Several constants like ATTEMPT_LATENCY, OPERATION_LATENCY, GAX_METRICS, and NUM_GAX_OTEL_METRICS are unused or related to the old logic and should be removed.

The test class needs to be revised to correctly test the behavior of AppCentricMetricsRecorder. This involves updating the verification methods to check for the gcp.client.request.duration metric and its properties (e.g., single data point per operation, correct final status).

*/
@Override
public void recordOperationLatency(double operationLatency, Map<String, String> attributes) {
requestDurationRecorder.record(operationLatency, toOtelAttributes(attributes));
Copy link
Contributor

Choose a reason for hiding this comment

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

high

There is a unit mismatch here. The Javadoc for operationLatency on line 74 specifies the unit as milliseconds (ms), but the requestDurationRecorder histogram is configured with seconds (s) as its unit on line 66. The value is being recorded without conversion.

This will lead to incorrect metric values (e.g., a latency of 100ms will be recorded as 100s).

Please convert the latency to seconds before recording.

Suggested change
requestDurationRecorder.record(operationLatency, toOtelAttributes(attributes));
requestDurationRecorder.record(operationLatency / 1000.0, toOtelAttributes(attributes));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants