From 45217207d752a8132927dff092f58b36dea4044e Mon Sep 17 00:00:00 2001 From: swathipil <76007337+swathipil@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:48:04 -0600 Subject: [PATCH] [EventHubs/ServiceBus] update network trace params to use empty strings not None (#34458) * update network trace params * update network trace params eh * update changelog --- sdk/eventhub/azure-eventhub/CHANGELOG.md | 4 ++++ .../azure-eventhub/azure/eventhub/_pyamqp/_connection.py | 2 +- .../azure-eventhub/azure/eventhub/_pyamqp/aio/_cbs_async.py | 2 +- .../azure/eventhub/_pyamqp/aio/_client_async.py | 4 ++-- .../azure/eventhub/_pyamqp/aio/_connection_async.py | 2 +- .../eventhub/_pyamqp/aio/_management_operation_async.py | 2 +- sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py | 2 +- .../azure-eventhub/azure/eventhub/_pyamqp/client.py | 6 +++--- .../azure/eventhub/_pyamqp/management_operation.py | 2 +- sdk/servicebus/azure-servicebus/CHANGELOG.md | 1 + .../azure/servicebus/_pyamqp/_connection.py | 2 +- .../azure/servicebus/_pyamqp/aio/_cbs_async.py | 2 +- .../azure/servicebus/_pyamqp/aio/_client_async.py | 4 ++-- .../azure/servicebus/_pyamqp/aio/_connection_async.py | 2 +- .../servicebus/_pyamqp/aio/_management_operation_async.py | 2 +- .../azure-servicebus/azure/servicebus/_pyamqp/cbs.py | 2 +- .../azure-servicebus/azure/servicebus/_pyamqp/client.py | 6 +++--- .../azure/servicebus/_pyamqp/management_operation.py | 2 +- 18 files changed, 27 insertions(+), 22 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index af477bb882db..eab898c3abea 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -10,14 +10,18 @@ ### Other Changes +- Updated network trace logging to replace `None` values in AMQP connection info with empty strings as per the OpenTelemetry specification. + ## 5.11.6 (2024-02-12) This version and all future versions will require Python 3.8+. Python 3.7 is no longer supported. ### Features Added + - Added `keep_alive` functionality on EventHubProducerClient to allow for long-living producers. [#33726](https://github.com/Azure/azure-sdk-for-python/issues/33726) ### Other Changes + - Added support for Python 3.12. ## 5.11.5 (2023-11-13) diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_connection.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_connection.py index febf4be03f1b..dbee7f17b42f 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_connection.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_connection.py @@ -135,7 +135,7 @@ def __init__( # pylint:disable=too-many-locals,too-many-statements custom_endpoint = f"{custom_parsed_url.hostname}:{custom_port}{custom_parsed_url.path}" self._container_id = container_id or str(uuid.uuid4()) self._network_trace = network_trace - self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": None, "amqpLink": None} + self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": "", "amqpLink": ""} transport = kwargs.get("transport") self._transport_type = transport_type 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 fd1969fe6984..9afa98a1017d 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 @@ -63,7 +63,7 @@ def __init__( self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._token_status_code: Optional[int] = None diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_client_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_client_async.py index 41828f8875f3..ab1df4e0f2ac 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_client_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_client_async.py @@ -304,8 +304,8 @@ async def close_async(self): if self._keep_alive_thread: await self._keep_alive_thread self._keep_alive_thread = None - self._network_trace_params["amqpConnection"] = None - self._network_trace_params["amqpSession"] = None + self._network_trace_params["amqpConnection"] = "" + self._network_trace_params["amqpSession"] = "" async def auth_complete_async(self): """Whether the authentication handshake is complete during diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_connection_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_connection_async.py index 6724427bfaa4..cfd4d09740b5 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_connection_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_connection_async.py @@ -116,7 +116,7 @@ def __init__(# pylint:disable=too-many-locals,too-many-statements custom_endpoint = f"{custom_parsed_url.hostname}:{custom_port}{custom_parsed_url.path}" self._container_id: str = container_id or str(uuid.uuid4()) self._network_trace = network_trace - self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": None, "amqpLink": None} + self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": "", "amqpLink": ""} transport = kwargs.get("transport") self._transport_type = transport_type diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_management_operation_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_management_operation_async.py index e312e8d67819..a21b1597f1c8 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_management_operation_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_management_operation_async.py @@ -31,7 +31,7 @@ def __init__(self, session, endpoint='$management', **kwargs): self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._mgmt_link: ManagementLink = self._session.create_request_response_link_pair( endpoint=endpoint, diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py index 86325845baf6..6ed43369ce3c 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/cbs.py @@ -81,7 +81,7 @@ def __init__( self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._token_status_code: Optional[int] = None diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/client.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/client.py index 6dea260dd9af..6ef1778a8ac4 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/client.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/client.py @@ -181,7 +181,7 @@ def __init__(self, hostname, **kwargs): "remote_idle_timeout_empty_frame_send_ratio", None ) self._network_trace = kwargs.pop("network_trace", False) - self._network_trace_params = {"amqpConnection": None, "amqpSession": None, "amqpLink": None} + self._network_trace_params = {"amqpConnection": "", "amqpSession": "", "amqpLink": ""} # Session settings self._outgoing_window = kwargs.pop("outgoing_window", OUTGOING_WINDOW) @@ -377,8 +377,8 @@ def close(self): except RuntimeError: # Probably thread failed to start in .open() logging.debug("Keep alive thread failed to join.", exc_info=True) self._keep_alive_thread = None - self._network_trace_params["amqpConnection"] = None - self._network_trace_params["amqpSession"] = None + self._network_trace_params["amqpConnection"] = "" + self._network_trace_params["amqpSession"] = "" def auth_complete(self): """Whether the authentication handshake is complete during diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/management_operation.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/management_operation.py index b59bb2e135d0..de707f4d6878 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/management_operation.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/management_operation.py @@ -31,7 +31,7 @@ def __init__(self, session, endpoint='$management', **kwargs): self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._mgmt_link: ManagementLink = self._session.create_request_response_link_pair( endpoint=endpoint, diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index e07eef7b7759..9bce79dd13c1 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -11,6 +11,7 @@ ### Other Changes - Updated minimum `azure-core` version to 1.28.0. +- Updated network trace logging to replace `None` values in AMQP connection info with empty strings as per the OpenTelemetry specification ([#32190](https://github.com/Azure/azure-sdk-for-python/issues/32190)). ## 7.11.4 (2023-11-13) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_connection.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_connection.py index febf4be03f1b..dbee7f17b42f 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_connection.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/_connection.py @@ -135,7 +135,7 @@ def __init__( # pylint:disable=too-many-locals,too-many-statements custom_endpoint = f"{custom_parsed_url.hostname}:{custom_port}{custom_parsed_url.path}" self._container_id = container_id or str(uuid.uuid4()) self._network_trace = network_trace - self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": None, "amqpLink": None} + self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": "", "amqpLink": ""} transport = kwargs.get("transport") self._transport_type = transport_type diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_cbs_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_cbs_async.py index 59e946112d40..325dcdd4742b 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_cbs_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_cbs_async.py @@ -63,7 +63,7 @@ def __init__( self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._token_status_code: Optional[int] = None diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_client_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_client_async.py index d59503af1967..ef194c45db7d 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_client_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_client_async.py @@ -304,8 +304,8 @@ async def close_async(self): if self._keep_alive_thread: await self._keep_alive_thread self._keep_alive_thread = None - self._network_trace_params["amqpConnection"] = None - self._network_trace_params["amqpSession"] = None + self._network_trace_params["amqpConnection"] = "" + self._network_trace_params["amqpSession"] = "" async def auth_complete_async(self): """Whether the authentication handshake is complete during diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_connection_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_connection_async.py index 6724427bfaa4..cfd4d09740b5 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_connection_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_connection_async.py @@ -116,7 +116,7 @@ def __init__(# pylint:disable=too-many-locals,too-many-statements custom_endpoint = f"{custom_parsed_url.hostname}:{custom_port}{custom_parsed_url.path}" self._container_id: str = container_id or str(uuid.uuid4()) self._network_trace = network_trace - self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": None, "amqpLink": None} + self._network_trace_params = {"amqpConnection": self._container_id, "amqpSession": "", "amqpLink": ""} transport = kwargs.get("transport") self._transport_type = transport_type diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_management_operation_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_management_operation_async.py index e312e8d67819..a21b1597f1c8 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_management_operation_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/aio/_management_operation_async.py @@ -31,7 +31,7 @@ def __init__(self, session, endpoint='$management', **kwargs): self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._mgmt_link: ManagementLink = self._session.create_request_response_link_pair( endpoint=endpoint, diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/cbs.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/cbs.py index fe2259d6acae..319b05c17d7f 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/cbs.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/cbs.py @@ -81,7 +81,7 @@ def __init__( self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._token_status_code: Optional[int] = None diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/client.py index 7038928fa3c5..05e61968c6b9 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/client.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/client.py @@ -181,7 +181,7 @@ def __init__(self, hostname, **kwargs): "remote_idle_timeout_empty_frame_send_ratio", None ) self._network_trace = kwargs.pop("network_trace", False) - self._network_trace_params = {"amqpConnection": None, "amqpSession": None, "amqpLink": None} + self._network_trace_params = {"amqpConnection": "", "amqpSession": "", "amqpLink": ""} # Session settings self._outgoing_window = kwargs.pop("outgoing_window", OUTGOING_WINDOW) @@ -377,8 +377,8 @@ def close(self): except RuntimeError: # Probably thread failed to start in .open() logging.debug("Keep alive thread failed to join.", exc_info=True) self._keep_alive_thread = None - self._network_trace_params["amqpConnection"] = None - self._network_trace_params["amqpSession"] = None + self._network_trace_params["amqpConnection"] = "" + self._network_trace_params["amqpSession"] = "" def auth_complete(self): """Whether the authentication handshake is complete during diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/management_operation.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/management_operation.py index b59bb2e135d0..de707f4d6878 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/management_operation.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp/management_operation.py @@ -31,7 +31,7 @@ def __init__(self, session, endpoint='$management', **kwargs): self._network_trace_params = { "amqpConnection": self._session._connection._container_id, "amqpSession": self._session.name, - "amqpLink": None + "amqpLink": "" } self._mgmt_link: ManagementLink = self._session.create_request_response_link_pair( endpoint=endpoint,