From d5199a4761e81ad198c0daa4b391dd6752920f9a Mon Sep 17 00:00:00 2001 From: GrantAnt Date: Wed, 27 Sep 2023 17:46:20 +0200 Subject: [PATCH 1/3] Allow redirect for proxy --- .../opencensus/ext/azure/common/transport.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 49fa2e1bc..92cd64ce7 100644 --- a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py +++ b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py @@ -111,13 +111,16 @@ def _transmit(self, envelopes): token = self.options.credential.get_token(_MONITOR_OAUTH_SCOPE) headers["Authorization"] = "Bearer {}".format(token.token) endpoint += '/v2.1/track' + proxies=json.loads(self.options.proxies) + allow_redirects=len(proxies) != 0 + response = requests.post( url=endpoint, - data=json.dumps(envelopes, default=str), + data=json.dumps(envelopes), headers=headers, timeout=self.options.timeout, - proxies=json.loads(self.options.proxies), - allow_redirects=False, + proxies=proxies, + allow_redirects=allow_redirects, ) except requests.Timeout as ex: if not self._is_stats_exporter(): From 019083d89ab7ed0df35c8d0de67a120fef746894 Mon Sep 17 00:00:00 2001 From: GrantAnt Date: Wed, 27 Sep 2023 17:51:37 +0200 Subject: [PATCH 2/3] Use latest code --- .../opencensus/ext/azure/common/transport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 92cd64ce7..6c8590a9f 100644 --- a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py +++ b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py @@ -116,7 +116,7 @@ def _transmit(self, envelopes): response = requests.post( url=endpoint, - data=json.dumps(envelopes), + data=json.dumps(envelopes, default=str), headers=headers, timeout=self.options.timeout, proxies=proxies, From 2aff9ef9f3ab55e21b4dd8038dc2c94ea1d86938 Mon Sep 17 00:00:00 2001 From: GrantAnt Date: Fri, 29 Sep 2023 09:45:30 +0200 Subject: [PATCH 3/3] Resolve flake8 --- .../opencensus/ext/azure/common/transport.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 6c8590a9f..ed0e1f8ec 100644 --- a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py +++ b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py @@ -111,8 +111,8 @@ def _transmit(self, envelopes): token = self.options.credential.get_token(_MONITOR_OAUTH_SCOPE) headers["Authorization"] = "Bearer {}".format(token.token) endpoint += '/v2.1/track' - proxies=json.loads(self.options.proxies) - allow_redirects=len(proxies) != 0 + proxies = json.loads(self.options.proxies) + allow_redirects = len(proxies) != 0 response = requests.post( url=endpoint,