From 67fdc67dd7e3339d3675f9c268f362a94ba4dddf Mon Sep 17 00:00:00 2001 From: Leighton Date: Tue, 28 Apr 2020 10:35:37 -0700 Subject: [PATCH 1/2] status 439 --- azure_monitor/src/azure_monitor/export/__init__.py | 2 ++ azure_monitor/tests/test_base_exporter.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/azure_monitor/src/azure_monitor/export/__init__.py b/azure_monitor/src/azure_monitor/export/__init__.py index e705a90..9f89ed6 100644 --- a/azure_monitor/src/azure_monitor/export/__init__.py +++ b/azure_monitor/src/azure_monitor/export/__init__.py @@ -144,6 +144,7 @@ def _transmit(self, envelopes: typing.List[Envelope]) -> ExportResult: for error in data["errors"]: if error["statusCode"] in ( 429, # Too Many Requests + 439, # Too Many Requests over extended time 500, # Internal Server Error 503, # Service Unavailable ): @@ -172,6 +173,7 @@ def _transmit(self, envelopes: typing.List[Envelope]) -> ExportResult: if response.status_code in ( 206, # Partial Content 429, # Too Many Requests + 439, # Too Many Requests over extended time 500, # Internal Server Error 503, # Service Unavailable ): diff --git a/azure_monitor/tests/test_base_exporter.py b/azure_monitor/tests/test_base_exporter.py index 8cbb6ab..da96cc1 100644 --- a/azure_monitor/tests/test_base_exporter.py +++ b/azure_monitor/tests/test_base_exporter.py @@ -191,7 +191,7 @@ def test_transmission_lease_failure(self, requests_mock): exporter._transmit_from_storage() self.assertTrue(exporter.storage.get()) - def test_(self): + def test_transmission(self): exporter = BaseExporter( storage_path=os.path.join(TEST_FOLDER, self.id()) ) @@ -316,6 +316,18 @@ def test_transmission_400(self): exporter._transmit_from_storage() self.assertEqual(len(os.listdir(exporter.storage.path)), 0) + def test_transmission_439(self): + exporter = BaseExporter( + storage_path=os.path.join(TEST_FOLDER, self.id()) + ) + envelopes_to_export = map(lambda x: x.to_dict(), tuple([Envelope()])) + exporter.storage.put(envelopes_to_export) + with mock.patch("requests.post") as post: + post.return_value = MockResponse(439, "{}") + exporter._transmit_from_storage() + self.assertIsNone(exporter.storage.get()) + self.assertEqual(len(os.listdir(exporter.storage.path)), 1) + def test_transmission_500(self): exporter = BaseExporter( storage_path=os.path.join(TEST_FOLDER, self.id()) From 49e28ac4e097037b8bfa105242c60fdde0dbd8d1 Mon Sep 17 00:00:00 2001 From: Leighton Date: Tue, 28 Apr 2020 12:14:15 -0700 Subject: [PATCH 2/2] update version --- azure_monitor/setup.cfg | 4 ++-- azure_monitor/src/azure_monitor/storage.py | 1 + azure_monitor/tests/metrics/test_metrics.py | 2 +- azure_monitor/tests/test_base_exporter.py | 2 +- azure_monitor/tests/test_storage.py | 2 +- azure_monitor/tests/trace/test_trace.py | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/azure_monitor/setup.cfg b/azure_monitor/setup.cfg index 496120e..31d9efc 100644 --- a/azure_monitor/setup.cfg +++ b/azure_monitor/setup.cfg @@ -27,8 +27,8 @@ package_dir= =src packages=find_namespace: install_requires = - opentelemetry-api >= 0.5b0 - opentelemetry-sdk >= 0.5b0 + opentelemetry-api >= 0.6b0 + opentelemetry-sdk >= 0.6b0 psutil >= 5.6.3 requests ~= 2.0 diff --git a/azure_monitor/src/azure_monitor/storage.py b/azure_monitor/src/azure_monitor/storage.py index 5c554cb..b04caa5 100644 --- a/azure_monitor/src/azure_monitor/storage.py +++ b/azure_monitor/src/azure_monitor/storage.py @@ -122,6 +122,7 @@ def _maintenance_routine(self, silent=False): if not silent: raise try: + # pylint: disable=unused-variable for blob in self.gets(): pass except Exception: diff --git a/azure_monitor/tests/metrics/test_metrics.py b/azure_monitor/tests/metrics/test_metrics.py index ee5e28e..276b49d 100644 --- a/azure_monitor/tests/metrics/test_metrics.py +++ b/azure_monitor/tests/metrics/test_metrics.py @@ -20,7 +20,7 @@ from azure_monitor.options import ExporterOptions from azure_monitor.protocol import Data, DataPoint, Envelope, MetricData -TEST_FOLDER = os.path.abspath(".test.exporter.trace") +TEST_FOLDER = os.path.abspath(".test") STORAGE_PATH = os.path.join(TEST_FOLDER) diff --git a/azure_monitor/tests/test_base_exporter.py b/azure_monitor/tests/test_base_exporter.py index da96cc1..7ac9370 100644 --- a/azure_monitor/tests/test_base_exporter.py +++ b/azure_monitor/tests/test_base_exporter.py @@ -19,7 +19,7 @@ from azure_monitor.options import ExporterOptions from azure_monitor.protocol import Data, Envelope -TEST_FOLDER = os.path.abspath(".test.exporter.base") +TEST_FOLDER = os.path.abspath(".test") STORAGE_PATH = os.path.join(TEST_FOLDER) diff --git a/azure_monitor/tests/test_storage.py b/azure_monitor/tests/test_storage.py index cee8cb6..4399444 100644 --- a/azure_monitor/tests/test_storage.py +++ b/azure_monitor/tests/test_storage.py @@ -13,7 +13,7 @@ _seconds, ) -TEST_FOLDER = os.path.abspath(".test.storage") +TEST_FOLDER = os.path.abspath(".test") # pylint: disable=invalid-name diff --git a/azure_monitor/tests/trace/test_trace.py b/azure_monitor/tests/trace/test_trace.py index 44d8853..da12706 100644 --- a/azure_monitor/tests/trace/test_trace.py +++ b/azure_monitor/tests/trace/test_trace.py @@ -18,7 +18,7 @@ from azure_monitor.export.trace import AzureMonitorSpanExporter from azure_monitor.options import ExporterOptions -TEST_FOLDER = os.path.abspath(".test.exporter.trace") +TEST_FOLDER = os.path.abspath(".test") STORAGE_PATH = os.path.join(TEST_FOLDER)