From 901c95ee902204c0e418e064d379516c6d133173 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Thu, 21 Nov 2024 15:14:35 -0800 Subject: [PATCH 1/2] stats --- contrib/opencensus-ext-azure/CHANGELOG.md | 6 +++++- .../opencensus/ext/azure/common/transport.py | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/opencensus-ext-azure/CHANGELOG.md b/contrib/opencensus-ext-azure/CHANGELOG.md index 174100a39..d64901ca9 100644 --- a/contrib/opencensus-ext-azure/CHANGELOG.md +++ b/contrib/opencensus-ext-azure/CHANGELOG.md @@ -2,9 +2,13 @@ ## Unreleased -# 1.1.13 +- Remove status code `206` from retry code + only count batch level for statsbeat +([#1239](https://github.com/census-instrumentation/opencensus-python/pull/1239)) + +## 1.1.13 Released 2024-01-03 + - Changed bit-mapping for `httpx` and `fastapi` integrations ([#1239](https://github.com/census-instrumentation/opencensus-python/pull/1239)) diff --git a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py index ed0e1f8ec..cf0cf622a 100644 --- a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py +++ b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py @@ -39,7 +39,6 @@ _REACHED_INGESTION_STATUS_CODES = (200, 206, 402, 408, 429, 439, 500) REDIRECT_STATUS_CODES = (307, 308) RETRYABLE_STATUS_CODES = ( - 206, # Partial success 401, # Unauthorized 403, # Forbidden 408, # Request Timeout @@ -214,8 +213,6 @@ def _transmit(self, envelopes): for error in data['errors']: if _status_code_is_retryable(error['statusCode']): resend_envelopes.append(envelopes[error['index']]) - if self._check_stats_collection(): - _update_requests_map('retry', value=error['statusCode']) # noqa: E501 else: if not self._is_stats_exporter(): logger.error( From 46b519eb64be80cfc8fd915e300ccac735c7a74a Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Thu, 21 Nov 2024 16:05:17 -0800 Subject: [PATCH 2/2] tests --- contrib/opencensus-ext-azure/CHANGELOG.md | 2 +- contrib/opencensus-ext-azure/tests/test_transport_mixin.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/opencensus-ext-azure/CHANGELOG.md b/contrib/opencensus-ext-azure/CHANGELOG.md index d64901ca9..ad8e8d689 100644 --- a/contrib/opencensus-ext-azure/CHANGELOG.md +++ b/contrib/opencensus-ext-azure/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased - Remove status code `206` from retry code + only count batch level for statsbeat -([#1239](https://github.com/census-instrumentation/opencensus-python/pull/1239)) +([#1247](https://github.com/census-instrumentation/opencensus-python/pull/1247)) ## 1.1.13 diff --git a/contrib/opencensus-ext-azure/tests/test_transport_mixin.py b/contrib/opencensus-ext-azure/tests/test_transport_mixin.py index 3a2c5d6aa..f955adfc5 100644 --- a/contrib/opencensus-ext-azure/tests/test_transport_mixin.py +++ b/contrib/opencensus-ext-azure/tests/test_transport_mixin.py @@ -454,9 +454,10 @@ def test_statsbeat_206_partial_retry(self): ], })) result = mixin._transmit([1, 2, 3]) - self.assertEqual(len(_requests_map), 3) + # We do not record any network statsbeat for 206 status code + self.assertEqual(len(_requests_map), 2) self.assertIsNotNone(_requests_map['duration']) - self.assertEqual(_requests_map['retry'][500], 1) + self.assertIsNone(_requests_map.get('retry')) self.assertEqual(_requests_map['count'], 1) self.assertEqual(result, TransportStatusCode.DROP) storage_mock.put.assert_called_once()