Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(bigtable): standardize client side metrics#17899
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
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -323,31 +323,35 @@ def test_on_attempt_complete_attempt_latencies(self): | ||
| ) | ||
| @pytest.mark.parametrize( | ||
| "is_first_attempt,flow_throttling_ns", | ||
| [(True, 54321), (False, 0), (True, 0)], | ||
| "op_type,flow_throttling_ns,should_record", | ||
| [ | ||
| (OperationType.BULK_MUTATE_ROWS, 54321, True), | ||
| (OperationType.BULK_MUTATE_ROWS, 0, False), | ||
| (OperationType.READ_ROWS, 54321, False), | ||
| ], | ||
| ) | ||
Comment on lines
325
to
332
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a test case where @pytest.mark.parametrize("op_type,flow_throttling_ns,should_record", [ (OperationType.BULK_MUTATE_ROWS, 54321, True), (OperationType.BULK_MUTATE_ROWS, 0, False), (OperationType.BULK_MUTATE_ROWS, None, False), (OperationType.READ_ROWS, 54321, False), ], ) | ||
| def test_on_attempt_complete_throttling_latencies( | ||
| self, is_first_attempt, flow_throttling_ns | ||
| def test_on_operation_complete_throttling_latencies( | ||
| self, op_type, flow_throttling_ns, should_record | ||
| ): | ||
| mock_instruments = mock.Mock(throttling_latencies=mock.Mock()) | ||
| handler = self._make_one(instruments=mock_instruments) | ||
| attempt = CompletedAttemptMetric( | ||
| op = CompletedOperationMetric( | ||
| op_type=op_type, | ||
| duration_ns=1234567, | ||
| end_status=StatusCode.OK, | ||
| ) | ||
| op = ActiveOperationMetric( | ||
| op_type=OperationType.READ_ROWS, | ||
| completed_attempts=[], | ||
| final_status=StatusCode.OK, | ||
| cluster_id="cluster", | ||
| zone="zone", | ||
| is_streaming=False, | ||
| flow_throttling_time_ns=flow_throttling_ns, | ||
| ) | ||
| if not is_first_attempt: | ||
| op.completed_attempts.append(mock.Mock()) | ||
| handler.on_attempt_complete(attempt, op) | ||
| expected_throttling = 0 | ||
| if is_first_attempt: | ||
| expected_throttling += flow_throttling_ns / 1e6 | ||
| mock_instruments.throttling_latencies.record.assert_called_once_with( | ||
| pytest.approx(expected_throttling), mock.ANY | ||
| ) | ||
| handler.on_operation_complete(op) | ||
| if should_record: | ||
| mock_instruments.throttling_latencies.record.assert_called_once_with( | ||
| pytest.approx(flow_throttling_ns / 1e6), mock.ANY | ||
| ) | ||
| else: | ||
| mock_instruments.throttling_latencies.record.assert_not_called() | ||
| def test_on_attempt_complete_application_latencies(self): | ||
| mock_instruments = mock.Mock(application_latencies=mock.Mock()) | ||
| @@ -361,8 +365,7 @@ def test_on_attempt_complete_application_latencies(self): | ||
| op = ActiveOperationMetric(op_type=OperationType.READ_ROWS) | ||
| handler.on_attempt_complete(attempt, op) | ||
| mock_instruments.application_latencies.record.assert_called_once_with( | ||
| (attempt.application_blocking_time_ns + attempt.backoff_before_attempt_ns) | ||
| / 1e6, | ||
| attempt.application_blocking_time_ns / 1e6, | ||
| mock.ANY, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
op.flow_throttling_time_nsisNone, evaluatingop.flow_throttling_time_ns > 0will raise aTypeErrorat runtime. Adding a defensive check to ensure it is notNonebefore comparison prevents potential crashes.