Skip to content

tests: Add metrics showcase tests for timeout case#12667

Open
blakeli0 wants to merge 1 commit intomainfrom
add-timeout-tests
Open

tests: Add metrics showcase tests for timeout case#12667
blakeli0 wants to merge 1 commit intomainfrom
add-timeout-tests

Conversation

@blakeli0
Copy link
Copy Markdown
Contributor

@blakeli0 blakeli0 commented Apr 3, 2026

Add showcase tests to ITOtelGoldenMetrics for client timeout.

@blakeli0 blakeli0 requested a review from lqiu96 April 3, 2026 03:34
@blakeli0 blakeli0 requested a review from a team as a code owner April 3, 2026 03:34
Copy link
Copy Markdown
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 adds integration tests to ITOtelGoldenMetrics.java to verify that OpenTelemetry metrics correctly record DEADLINE_EXCEEDED statuses for gRPC and HTTP/JSON calls. To support these tests, new helper methods were added to TestClientInitializer.java for initializing clients with custom RetrySettings. The review feedback recommends using the more specific DeadlineExceededException in the test assertions instead of the generic Exception class to ensure the tests are validating the intended failure mode.

import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.rpc.StatusCode;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.TransportChannelProvider;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The new test cases use DeadlineExceededException. Please add the corresponding import to support the more specific assertions.

Suggested change
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.DeadlineExceededException;
import com.google.api.gax.rpc.TransportChannelProvider;

tracerFactory, zeroRetrySettings)) {

assertThrows(
Exception.class,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a more specific exception class like DeadlineExceededException.class is preferred over Exception.class. This ensures the test specifically validates the timeout behavior and doesn't pass due to unrelated errors (e.g., configuration issues).

Suggested change
Exception.class,
DeadlineExceededException.class,

tracerFactory, zeroRetrySettings)) {

assertThrows(
Exception.class,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a more specific exception class like DeadlineExceededException.class is preferred over Exception.class. This ensures the test specifically validates the timeout behavior and doesn't pass due to unrelated errors.

Suggested change
Exception.class,
DeadlineExceededException.class,

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.

1 participant