From 141df3a35dd56fedab68377edcb9c8b1478d4595 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Mon, 18 Jul 2022 09:17:53 -0500 Subject: [PATCH 01/12] enhanced logging for linkedin --- .../azure-eventhub/azure/eventhub/_client_base.py | 15 +++++++++++++-- .../azure/eventhub/_producer_client.py | 6 +++++- .../azure/eventhub/_pyamqp/aio/_cbs_async.py | 2 ++ .../azure-eventhub/azure/eventhub/_pyamqp/cbs.py | 8 ++++++++ .../azure/eventhub/aio/_client_base_async.py | 7 ++++++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py index 4fd65f126086..f1cc41dd3479 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py @@ -10,7 +10,7 @@ import functools import collections from typing import Any, Dict, Tuple, List, Optional, TYPE_CHECKING, cast, Union -from datetime import timedelta +from datetime import timedelta, datetime from urllib.parse import urlparse import six @@ -386,7 +386,14 @@ def _management_request(self, mgmt_msg, op_type): mgmt_client.open() while not mgmt_client.client_ready(): time.sleep(0.05) - mgmt_msg.application_properties["security_token"] = mgmt_auth.get_token() + access_token = mgmt_auth.get_token() + mgmt_msg.application_properties["security_token"] = access_token.token + if not access_token.token: + _LOGGER.info("Management client received an empty token") + + else: + _LOGGER.info(f"Management client token expires on: {datetime.fromtimestamp(access_token.expires_on)}") + response = mgmt_client.mgmt_request( mgmt_msg, operation=READ_OPERATION.decode(), @@ -394,6 +401,10 @@ def _management_request(self, mgmt_msg, op_type): status_code_field=MGMT_STATUS_CODE, description_fields=MGMT_STATUS_DESC, ) + _LOGGER.info( + 'Management client token expiry: %r', + datetime.fromtimestamp(access_token.expires_on) + ) status_code = int(response.application_properties[MGMT_STATUS_CODE]) description = response.application_properties.get( MGMT_STATUS_DESC diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_producer_client.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_producer_client.py index 6a6cfb181c1a..84b5ea1a5056 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_producer_client.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_producer_client.py @@ -117,6 +117,7 @@ def __exit__(self, *args): def _get_partitions(self): # type: () -> None if not self._partition_ids: + _LOGGER.info("Populating partition IDs so producers can be started.") self._partition_ids = self.get_partition_ids() # type: ignore for p_id in cast(List[str], self._partition_ids): self._producers[p_id] = None @@ -311,7 +312,9 @@ def send_batch(self, event_data_batch, **kwargs): cast(EventHubProducer, self._producers[partition_id]).send( to_send_batch, timeout=send_timeout ) - except (KeyError, AttributeError, EventHubError): + except (KeyError, AttributeError, EventHubError) as e: + _LOGGER.info( + "Producer for partition ID '{}' not available: {}. Rebuilding new producer.".format(partition_id, e)) self._start_producer(partition_id, send_timeout) cast(EventHubProducer, self._producers[partition_id]).send( to_send_batch, timeout=send_timeout @@ -431,6 +434,7 @@ def close(self): :caption: Close down the client. """ + _LOGGER.info("Closing ProducerClient") with self._lock: for pid in self._producers: if self._producers[pid]: diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_cbs_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_cbs_async.py index c7f4e8c94b59..7757db7f2024 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_cbs_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_cbs_async.py @@ -175,6 +175,8 @@ async def close(self): async def update_token(self): self.auth_state = CbsAuthState.IN_PROGRESS access_token = await self._auth.get_token() + if not access_token.token: + _LOGGER.debug("update_token received an empty token") self._expires_on = access_token.expires_on expires_in = self._expires_on - int(utc_now().timestamp()) self._refresh_window = int(float(expires_in) * 0.1) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py index 5813475f050b..407bf4330e26 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py @@ -152,12 +152,15 @@ def _on_execute_operation_complete( def _update_status(self): if self.auth_state == CbsAuthState.OK or self.auth_state == CbsAuthState.REFRESH_REQUIRED: + _LOGGER.info('update_status In refresh required or OK.') is_expired, is_refresh_required = check_expiration_and_refresh_status(self._expires_on, self._refresh_window) + _LOGGER.info('is expired == %r, is refresh required == %r', is_expired, is_refresh_required) if is_expired: self.auth_state = CbsAuthState.EXPIRED elif is_refresh_required: self.auth_state = CbsAuthState.REFRESH_REQUIRED elif self.auth_state == CbsAuthState.IN_PROGRESS: + _LOGGER.info('In update status, in progress. token put time: %r', self._token_put_time) put_timeout = check_put_timeout_status(self._auth_timeout, self._token_put_time) if put_timeout: self.auth_state = CbsAuthState.TIMEOUT @@ -186,7 +189,12 @@ def close(self): def update_token(self): self.auth_state = CbsAuthState.IN_PROGRESS access_token = self._auth.get_token() + if not access_token.token: + _LOGGER.info("Update_token received an empty token") self._expires_on = access_token.expires_on + _LOGGER.info('Update_token after token has been updated') + _LOGGER.info('Current time: %r', datetime.now()) + _LOGGER.info('Token expiry: %r', datetime.fromtimestamp(self._expires_on)) expires_in = self._expires_on - int(utc_now().timestamp()) self._refresh_window = int(float(expires_in) * 0.1) try: diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/aio/_client_base_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/aio/_client_base_async.py index dc6fb2e79054..90a8a9e594ca 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/aio/_client_base_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/aio/_client_base_async.py @@ -265,7 +265,12 @@ async def _management_request_async(self, mgmt_msg: Message, op_type: bytes) -> await mgmt_client.open_async() while not (await mgmt_client.client_ready_async()): await asyncio.sleep(0.05) - mgmt_msg.application_properties["security_token"] = await mgmt_auth.get_token() + access_token = await mgmt_auth.get_token() + mgmt_msg.application_properties["security_token"] = access_token.token + + if not access_token.token: + _LOGGER.info("update_token received an empty token") + response = await mgmt_client.mgmt_request_async( mgmt_msg, operation=READ_OPERATION.decode(), From 623d4bfa4aa4b0a53081ba838ba550792b997627 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Mon, 18 Jul 2022 09:18:05 -0500 Subject: [PATCH 02/12] stuff --- .../samples/sync_samples/send.py | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py index 0173ba5b8e0f..318d684f76ba 100644 --- a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py +++ b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py @@ -9,19 +9,23 @@ Examples to show sending events with different options to an Event Hub partition. """ +import logging +import sys import time import os +from tkinter.tix import Tree from azure.eventhub import EventHubProducerClient, EventData from azure.eventhub.exceptions import EventHubError +from azure.identity import DefaultAzureCredential -CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] -EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] - +# CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] +# EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] def send_event_data_batch(producer): # Without specifying partition_id or partition_key # the events will be distributed to available partitions via round-robin. event_data_batch = producer.create_batch() + producer.close() event_data_batch.add(EventData('Single message')) producer.send_batch(event_data_batch) @@ -82,18 +86,24 @@ def send_event_data_list(producer): print("Sending error: ", eh_err) -producer = EventHubProducerClient.from_connection_string( - conn_str=CONNECTION_STR, - eventhub_name=EVENTHUB_NAME -) +logger = logging.getLogger('azure.eventhub') +logger.setLevel(logging.DEBUG) +handler = logging.StreamHandler(stream=sys.stdout) +logger.addHandler(handler) +uamqp_logger = logging.getLogger('pyamqp') +uamqp_logger.setLevel(logging.DEBUG) +uamqp_logger.addHandler(handler) + +producer = EventHubProducerClient('eh-kashifk.servicebus.windows.net', 'eh-kashifk-hub', credential=DefaultAzureCredential(logging_enable = True), logging_enable=True) + start_time = time.time() with producer: send_event_data_batch(producer) - send_event_data_batch_with_limited_size(producer) - send_event_data_batch_with_partition_key(producer) - send_event_data_batch_with_partition_id(producer) - send_event_data_batch_with_properties(producer) - send_event_data_list(producer) + # send_event_data_batch_with_limited_size(producer) + # send_event_data_batch_with_partition_key(producer) + # send_event_data_batch_with_partition_id(producer) + # send_event_data_batch_with_properties(producer) + # send_event_data_list(producer) -print("Send messages in {} seconds.".format(time.time() - start_time)) +print("Send messages in {} seconds.".format(time.time() - start_time)) \ No newline at end of file From 7c997d5840f6640335abbbf629010f6073a61482 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 14:00:26 -0500 Subject: [PATCH 03/12] fixes --- .../azure/eventhub/_client_base.py | 13 +++++----- .../samples/sync_samples/send.py | 26 ++++++++----------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py index f1cc41dd3479..552849f3331f 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py @@ -387,12 +387,17 @@ def _management_request(self, mgmt_msg, op_type): while not mgmt_client.client_ready(): time.sleep(0.05) access_token = mgmt_auth.get_token() - mgmt_msg.application_properties["security_token"] = access_token.token - if not access_token.token: + + if not access_token: + _LOGGER.info("Management client received an access token object") + + elif not access_token.token: _LOGGER.info("Management client received an empty token") else: _LOGGER.info(f"Management client token expires on: {datetime.fromtimestamp(access_token.expires_on)}") + + mgmt_msg.application_properties["security_token"] = access_token.token response = mgmt_client.mgmt_request( mgmt_msg, @@ -401,10 +406,6 @@ def _management_request(self, mgmt_msg, op_type): status_code_field=MGMT_STATUS_CODE, description_fields=MGMT_STATUS_DESC, ) - _LOGGER.info( - 'Management client token expiry: %r', - datetime.fromtimestamp(access_token.expires_on) - ) status_code = int(response.application_properties[MGMT_STATUS_CODE]) description = response.application_properties.get( MGMT_STATUS_DESC diff --git a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py index 318d684f76ba..eba32795e430 100644 --- a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py +++ b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py @@ -18,8 +18,8 @@ from azure.eventhub.exceptions import EventHubError from azure.identity import DefaultAzureCredential -# CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] -# EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] +CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] +EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] def send_event_data_batch(producer): # Without specifying partition_id or partition_key @@ -86,24 +86,20 @@ def send_event_data_list(producer): print("Sending error: ", eh_err) -logger = logging.getLogger('azure.eventhub') -logger.setLevel(logging.DEBUG) -handler = logging.StreamHandler(stream=sys.stdout) -logger.addHandler(handler) -uamqp_logger = logging.getLogger('pyamqp') -uamqp_logger.setLevel(logging.DEBUG) -uamqp_logger.addHandler(handler) -producer = EventHubProducerClient('eh-kashifk.servicebus.windows.net', 'eh-kashifk-hub', credential=DefaultAzureCredential(logging_enable = True), logging_enable=True) +producer = EventHubProducerClient.from_connection_string( + conn_str=CONNECTION_STR, + eventhub_name=EVENTHUB_NAME +) start_time = time.time() with producer: send_event_data_batch(producer) - # send_event_data_batch_with_limited_size(producer) - # send_event_data_batch_with_partition_key(producer) - # send_event_data_batch_with_partition_id(producer) - # send_event_data_batch_with_properties(producer) - # send_event_data_list(producer) + send_event_data_batch_with_limited_size(producer) + send_event_data_batch_with_partition_key(producer) + send_event_data_batch_with_partition_id(producer) + send_event_data_batch_with_properties(producer) + send_event_data_list(producer) print("Send messages in {} seconds.".format(time.time() - start_time)) \ No newline at end of file From 283bad80c8944e808a0fb18c30716efd04482dd1 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 14:01:39 -0500 Subject: [PATCH 04/12] minor sample fix --- sdk/eventhub/azure-eventhub/samples/sync_samples/send.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py index eba32795e430..f9130abaac1b 100644 --- a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py +++ b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py @@ -25,7 +25,6 @@ def send_event_data_batch(producer): # Without specifying partition_id or partition_key # the events will be distributed to available partitions via round-robin. event_data_batch = producer.create_batch() - producer.close() event_data_batch.add(EventData('Single message')) producer.send_batch(event_data_batch) From 015fbd1d37c18a99d24000691e5a511de6e10c41 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 14:24:46 -0500 Subject: [PATCH 05/12] Changelog --- sdk/eventhub/azure-eventhub/CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index 026bc3170242..12b1e39b5e22 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -1,14 +1,16 @@ # Release History -## 5.8.0b5 (Unreleased) +## 5.8.0b5 (2022-07-19) ### Features Added ### Breaking Changes ### Bugs Fixed - +- Bug fixes that would prevent token refresh at regular intervals +- Pass in the proper kwarg, so that debug levels will be output when requested ### Other Changes +- Specific logging added in to track error scenarios ## 5.8.0a4 (2022-06-07) From 5263c361f127958913fa1d870d55c9de50b95b98 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 14:40:07 -0500 Subject: [PATCH 06/12] remove unused imports --- sdk/eventhub/azure-eventhub/samples/sync_samples/send.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py index f9130abaac1b..84985720569a 100644 --- a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py +++ b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py @@ -8,15 +8,10 @@ """ Examples to show sending events with different options to an Event Hub partition. """ - -import logging -import sys import time import os -from tkinter.tix import Tree from azure.eventhub import EventHubProducerClient, EventData from azure.eventhub.exceptions import EventHubError -from azure.identity import DefaultAzureCredential CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] From 005fb0511c7897acf85541f54f8d393763c237a3 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 15:11:58 -0500 Subject: [PATCH 07/12] fix formatting changes --- sdk/eventhub/azure-eventhub/CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index 12b1e39b5e22..f79ea9ec54e0 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -2,14 +2,12 @@ ## 5.8.0b5 (2022-07-19) -### Features Added - -### Breaking Changes - ### Bugs Fixed + - Bug fixes that would prevent token refresh at regular intervals - Pass in the proper kwarg, so that debug levels will be output when requested ### Other Changes + - Specific logging added in to track error scenarios ## 5.8.0a4 (2022-06-07) From bc8f6e794c99a00bd07107181056d6b5d8b4239a Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 16:09:54 -0500 Subject: [PATCH 08/12] change debug level --- .../azure-eventhub/azure/eventhub/_pyamqp/cbs.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py index 407bf4330e26..267283e01759 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py @@ -152,15 +152,15 @@ def _on_execute_operation_complete( def _update_status(self): if self.auth_state == CbsAuthState.OK or self.auth_state == CbsAuthState.REFRESH_REQUIRED: - _LOGGER.info('update_status In refresh required or OK.') + _LOGGER.debug('update_status In refresh required or OK.') is_expired, is_refresh_required = check_expiration_and_refresh_status(self._expires_on, self._refresh_window) - _LOGGER.info('is expired == %r, is refresh required == %r', is_expired, is_refresh_required) + _LOGGER.debug('is expired == %r, is refresh required == %r', is_expired, is_refresh_required) if is_expired: self.auth_state = CbsAuthState.EXPIRED elif is_refresh_required: self.auth_state = CbsAuthState.REFRESH_REQUIRED elif self.auth_state == CbsAuthState.IN_PROGRESS: - _LOGGER.info('In update status, in progress. token put time: %r', self._token_put_time) + _LOGGER.debug('In update status, in progress. token put time: %r', self._token_put_time) put_timeout = check_put_timeout_status(self._auth_timeout, self._token_put_time) if put_timeout: self.auth_state = CbsAuthState.TIMEOUT @@ -189,7 +189,9 @@ def close(self): def update_token(self): self.auth_state = CbsAuthState.IN_PROGRESS access_token = self._auth.get_token() - if not access_token.token: + if not access_token: + _LOGGER.info("Update_token received an empty token object") + elif not access_token.token: _LOGGER.info("Update_token received an empty token") self._expires_on = access_token.expires_on _LOGGER.info('Update_token after token has been updated') From 5b288ab33edd25df69bb8a0067eefe076e8b9925 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 16:57:23 -0500 Subject: [PATCH 09/12] update version info --- sdk/eventhub/azure-eventhub/CHANGELOG.md | 2 +- sdk/eventhub/azure-eventhub/azure/eventhub/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index f79ea9ec54e0..68483c986eac 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 5.8.0b5 (2022-07-19) +## 5.8.0a5 (2022-07-19) ### Bugs Fixed diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py index 144ff61d3dc6..02ba7f8b776f 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "5.8.0b5" +VERSION = "5.8.0a5" From 1acb290d699f7382574ebc4c8a762b6c211ba443 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 17:03:45 -0500 Subject: [PATCH 10/12] update changelog --- sdk/eventhub/azure-eventhub/CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index 68483c986eac..10ef4c81b221 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -4,11 +4,12 @@ ### Bugs Fixed -- Bug fixes that would prevent token refresh at regular intervals -- Pass in the proper kwarg, so that debug levels will be output when requested +- Fixed bug that prevented token refresh at regular intervals. +- Fixed bug that was improperly passing the debug keyword argument, so that network trace debug logs are output when requested. + ### Other Changes -- Specific logging added in to track error scenarios +- Added logging added in to track proper token refreshes & fetches, output exception reason for producer init failure. ## 5.8.0a4 (2022-06-07) From 6e82a9211ed245a877c05d720d406f38abcf6dd6 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 17:03:56 -0500 Subject: [PATCH 11/12] fix sample --- sdk/eventhub/azure-eventhub/samples/sync_samples/send.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py index 84985720569a..129d429d6473 100644 --- a/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py +++ b/sdk/eventhub/azure-eventhub/samples/sync_samples/send.py @@ -96,4 +96,4 @@ def send_event_data_list(producer): send_event_data_batch_with_properties(producer) send_event_data_list(producer) -print("Send messages in {} seconds.".format(time.time() - start_time)) \ No newline at end of file +print("Send messages in {} seconds.".format(time.time() - start_time)) From e0e714943188c33cc211873fdc4ebcf52949689e Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 19 Jul 2022 17:08:51 -0500 Subject: [PATCH 12/12] fix logging message for empty access token --- sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py index 552849f3331f..73b833b54873 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py @@ -389,14 +389,14 @@ def _management_request(self, mgmt_msg, op_type): access_token = mgmt_auth.get_token() if not access_token: - _LOGGER.info("Management client received an access token object") + _LOGGER.info("Management client received an empty access token object") elif not access_token.token: _LOGGER.info("Management client received an empty token") else: _LOGGER.info(f"Management client token expires on: {datetime.fromtimestamp(access_token.expires_on)}") - + mgmt_msg.application_properties["security_token"] = access_token.token response = mgmt_client.mgmt_request(