tests: Add metrics showcase tests for timeout case#12667
tests: Add metrics showcase tests for timeout case#12667
Conversation
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
The new test cases use DeadlineExceededException. Please add the corresponding import to support the more specific assertions.
| 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, |
There was a problem hiding this comment.
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).
| Exception.class, | |
| DeadlineExceededException.class, |
| tracerFactory, zeroRetrySettings)) { | ||
|
|
||
| assertThrows( | ||
| Exception.class, |
There was a problem hiding this comment.
Add showcase tests to ITOtelGoldenMetrics for client timeout.