From 4c72960d5a793353af47feeeea82db82775fdbaf Mon Sep 17 00:00:00 2001 From: antisch Date: Mon, 4 Sep 2023 08:09:13 +1200 Subject: [PATCH 1/3] Make subnamespaces internal --- .../__init__.py | 0 .../configurator.py} | 2 +- .../distro.py} | 4 +- .../azure/monitor/opentelemetry/_configure.py | 2 +- .../{diagnostics => _diagnostics}/__init__.py | 0 .../diagnostic_logging.py} | 0 .../status_logger.py} | 0 .../opentelemetry/{util => _util}/__init__.py | 0 .../configurations.py} | 0 .../azure-monitor-opentelemetry/setup.py | 4 +- .../autoinstrumentation/test_configurator.py | 10 +-- .../tests/autoinstrumentation/test_distro.py | 14 +-- .../tests/configuration/test_util.py | 2 +- .../diagnostics/test_diagnostic_logging.py | 14 +-- .../tests/diagnostics/test_status_logger.py | 90 +++++++++---------- 15 files changed, 71 insertions(+), 71 deletions(-) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{autoinstrumentation => _autoinstrumentation}/__init__.py (100%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{autoinstrumentation/_configurator.py => _autoinstrumentation/configurator.py} (95%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{autoinstrumentation/_distro.py => _autoinstrumentation/distro.py} (95%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{diagnostics => _diagnostics}/__init__.py (100%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{diagnostics/_diagnostic_logging.py => _diagnostics/diagnostic_logging.py} (100%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{diagnostics/_status_logger.py => _diagnostics/status_logger.py} (100%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{util => _util}/__init__.py (100%) rename sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/{util/_configurations.py => _util/configurations.py} (100%) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/__init__.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/__init__.py similarity index 100% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/__init__.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/__init__.py diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/_configurator.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/configurator.py similarity index 95% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/_configurator.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/configurator.py index c3bedbae6504..bc990e74cd28 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/_configurator.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/configurator.py @@ -14,7 +14,7 @@ _is_attach_enabled, _PREVIEW_ENTRY_POINT_WARNING, ) -from azure.monitor.opentelemetry.diagnostics._diagnostic_logging import ( +from azure.monitor.opentelemetry._diagnostics.diagnostic_logging import ( AzureDiagnosticLogging, ) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/_distro.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py similarity index 95% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/_distro.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py index e9c13f77f9da..cdc45ce2adbc 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/autoinstrumentation/_distro.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py @@ -25,10 +25,10 @@ _is_attach_enabled, _PREVIEW_ENTRY_POINT_WARNING, ) -from azure.monitor.opentelemetry.diagnostics._diagnostic_logging import ( +from azure.monitor.opentelemetry._diagnostics.diagnostic_logging import ( AzureDiagnosticLogging, ) -from azure.monitor.opentelemetry.diagnostics._status_logger import ( +from azure.monitor.opentelemetry._diagnostics.status_logger import ( AzureStatusLogger, ) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index a19510872ceb..8c0389e32d5d 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -40,7 +40,7 @@ AzureMonitorMetricExporter, AzureMonitorTraceExporter, ) -from azure.monitor.opentelemetry.util._configurations import _get_configurations +from azure.monitor.opentelemetry._util.configurations import _get_configurations _logger = getLogger(__name__) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/diagnostics/__init__.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/__init__.py similarity index 100% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/diagnostics/__init__.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/__init__.py diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/diagnostics/_diagnostic_logging.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/diagnostic_logging.py similarity index 100% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/diagnostics/_diagnostic_logging.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/diagnostic_logging.py diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/diagnostics/_status_logger.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/status_logger.py similarity index 100% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/diagnostics/_status_logger.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/status_logger.py diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/util/__init__.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_util/__init__.py similarity index 100% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/util/__init__.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_util/__init__.py diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/util/_configurations.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_util/configurations.py similarity index 100% rename from sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/util/_configurations.py rename to sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_util/configurations.py diff --git a/sdk/monitor/azure-monitor-opentelemetry/setup.py b/sdk/monitor/azure-monitor-opentelemetry/setup.py index 1711f99cd10e..558575748ece 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/setup.py +++ b/sdk/monitor/azure-monitor-opentelemetry/setup.py @@ -99,10 +99,10 @@ ], entry_points={ "opentelemetry_distro": [ - "azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry.autoinstrumentation._distro:AzureMonitorDistro" + "azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry._autoinstrumentation.distro:AzureMonitorDistro" ], "opentelemetry_configurator": [ - "azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.autoinstrumentation._configurator:AzureMonitorConfigurator" + "azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry._autoinstrumentation.configurator:AzureMonitorConfigurator" ], }, ) diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_configurator.py b/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_configurator.py index 72897c09d918..f6a41c7c3770 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_configurator.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_configurator.py @@ -3,15 +3,15 @@ from unittest.mock import patch from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan -from azure.monitor.opentelemetry.autoinstrumentation._configurator import ( +from azure.monitor.opentelemetry._autoinstrumentation.configurator import ( AzureMonitorConfigurator, ) class TestConfigurator(TestCase): - @patch("azure.monitor.opentelemetry.autoinstrumentation._configurator._is_attach_enabled", return_value=True) + @patch("azure.monitor.opentelemetry._autoinstrumentation.configurator._is_attach_enabled", return_value=True) @patch( - "azure.monitor.opentelemetry.autoinstrumentation._configurator.AzureDiagnosticLogging.enable" + "azure.monitor.opentelemetry._autoinstrumentation.configurator.AzureDiagnosticLogging.enable" ) def test_configure(self, mock_diagnostics, attach_mock): configurator = AzureMonitorConfigurator() @@ -20,9 +20,9 @@ def test_configure(self, mock_diagnostics, attach_mock): configurator._configure() mock_diagnostics.assert_called_once() - @patch("azure.monitor.opentelemetry.autoinstrumentation._configurator._is_attach_enabled", return_value=False) + @patch("azure.monitor.opentelemetry._autoinstrumentation.configurator._is_attach_enabled", return_value=False) @patch( - "azure.monitor.opentelemetry.autoinstrumentation._configurator.AzureDiagnosticLogging.enable" + "azure.monitor.opentelemetry._autoinstrumentation.configurator.AzureDiagnosticLogging.enable" ) def test_configure_preview(self, mock_diagnostics, attach_mock): configurator = AzureMonitorConfigurator() diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py b/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py index 1b91ae1de8c6..36a5be11ae5a 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py @@ -3,16 +3,16 @@ from unittest.mock import patch from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan -from azure.monitor.opentelemetry.autoinstrumentation._distro import ( +from azure.monitor.opentelemetry._autoinstrumentation.distro import ( AzureMonitorDistro, ) class TestDistro(TestCase): - @patch("azure.monitor.opentelemetry.autoinstrumentation._distro._is_attach_enabled", return_value=True) - @patch("azure.monitor.opentelemetry.autoinstrumentation._distro.settings") + @patch("azure.monitor.opentelemetry._autoinstrumentation.distro._is_attach_enabled", return_value=True) + @patch("azure.monitor.opentelemetry._autoinstrumentation.distro.settings") @patch( - "azure.monitor.opentelemetry.autoinstrumentation._distro.AzureDiagnosticLogging.enable" + "azure.monitor.opentelemetry._autoinstrumentation.distro.AzureDiagnosticLogging.enable" ) def test_configure(self, mock_diagnostics, azure_core_mock, attach_mock): distro = AzureMonitorDistro() @@ -24,10 +24,10 @@ def test_configure(self, mock_diagnostics, azure_core_mock, attach_mock): azure_core_mock.tracing_implementation, OpenTelemetrySpan ) - @patch("azure.monitor.opentelemetry.autoinstrumentation._distro._is_attach_enabled", return_value=False) - @patch("azure.monitor.opentelemetry.autoinstrumentation._distro.settings") + @patch("azure.monitor.opentelemetry._autoinstrumentation.distro._is_attach_enabled", return_value=False) + @patch("azure.monitor.opentelemetry._autoinstrumentation.distro.settings") @patch( - "azure.monitor.opentelemetry.autoinstrumentation._distro.AzureDiagnosticLogging.enable" + "azure.monitor.opentelemetry._autoinstrumentation.distro.AzureDiagnosticLogging.enable" ) def test_configure_preview(self, mock_diagnostics, azure_core_mock, attach_mock): distro = AzureMonitorDistro() diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/configuration/test_util.py b/sdk/monitor/azure-monitor-opentelemetry/tests/configuration/test_util.py index 47181905fcf2..6ddba50805c6 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/configuration/test_util.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/configuration/test_util.py @@ -18,7 +18,7 @@ from opentelemetry.instrumentation.environment_variables import ( OTEL_PYTHON_DISABLED_INSTRUMENTATIONS, ) -from azure.monitor.opentelemetry.util._configurations import ( +from azure.monitor.opentelemetry._util.configurations import ( SAMPLING_RATIO_ENV_VAR, _get_configurations, ) diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_diagnostic_logging.py b/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_diagnostic_logging.py index 41ec047a42b8..dbb77110636a 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_diagnostic_logging.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_diagnostic_logging.py @@ -12,7 +12,7 @@ from unittest import TestCase from unittest.mock import patch -import azure.monitor.opentelemetry.diagnostics._diagnostic_logging as diagnostic_logger +import azure.monitor.opentelemetry._diagnostics.diagnostic_logging as diagnostic_logger TEST_LOGGER_PATH = str(Path.home()) TEST_DIAGNOSTIC_LOGGER_FILE_NAME_TEMPLATE = "test-applicationinsights-extension-%s.log" @@ -95,27 +95,27 @@ def set_up( reload(diagnostic_logger) assert not diagnostic_logger.AzureDiagnosticLogging._initialized patch( - "azure.monitor.opentelemetry.diagnostics._diagnostic_logging._DIAGNOSTIC_LOG_PATH", + "azure.monitor.opentelemetry._diagnostics.diagnostic_logging._DIAGNOSTIC_LOG_PATH", TEST_LOGGER_PATH, ).start() patch( - "azure.monitor.opentelemetry.diagnostics._diagnostic_logging._DIAGNOSTIC_LOGGER_FILE_NAME", + "azure.monitor.opentelemetry._diagnostics.diagnostic_logging._DIAGNOSTIC_LOGGER_FILE_NAME", get_test_file_name(test_id), ).start() patch( - "azure.monitor.opentelemetry.diagnostics._diagnostic_logging._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.diagnostic_logging._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ).start() patch( - "azure.monitor.opentelemetry.diagnostics._diagnostic_logging._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.diagnostic_logging._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ).start() patch( - "azure.monitor.opentelemetry.diagnostics._diagnostic_logging.VERSION", + "azure.monitor.opentelemetry._diagnostics.diagnostic_logging.VERSION", TEST_VERSION, ).start() patch( - "azure.monitor.opentelemetry.diagnostics._diagnostic_logging._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.diagnostic_logging._IS_DIAGNOSTICS_ENABLED", is_diagnostics_enabled, ).start() diagnostic_logger.AzureDiagnosticLogging.enable(logger) diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_status_logger.py b/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_status_logger.py index 9d6cd5e828d3..18bcf0f6b9e7 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_status_logger.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/diagnostics/test_status_logger.py @@ -10,7 +10,7 @@ from unittest import TestCase from unittest.mock import patch -from azure.monitor.opentelemetry.diagnostics._status_logger import ( +from azure.monitor.opentelemetry._diagnostics.status_logger import ( AzureStatusLogger, _get_status_logger_file_name ) @@ -76,36 +76,36 @@ class TestStatusLogger(TestCase): def setUp(self) -> None: clear_file(test_id=self.id()) patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_status_logger_file_name", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_status_logger_file_name", return_value=get_test_file_name(self.id()), ).start() @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._STATUS_LOG_PATH", + "azure.monitor.opentelemetry._diagnostics.status_logger._STATUS_LOG_PATH", TEST_LOGGER_PATH, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger.VERSION", TEST_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.status_logger._IS_DIAGNOSTICS_ENABLED", True, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.getpid", + "azure.monitor.opentelemetry._diagnostics.status_logger.getpid", return_value=TEST_PID, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_log_status_success(self, mock_getpid, mock_get_ikey): @@ -114,31 +114,31 @@ def test_log_status_success(self, mock_getpid, mock_get_ikey): check_file_for_messages(True, self.id(), MESSAGE2) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._STATUS_LOG_PATH", + "azure.monitor.opentelemetry._diagnostics.status_logger._STATUS_LOG_PATH", TEST_LOGGER_PATH, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger.VERSION", TEST_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.status_logger._IS_DIAGNOSTICS_ENABLED", True, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.getpid", + "azure.monitor.opentelemetry._diagnostics.status_logger.getpid", return_value=TEST_PID, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_log_status_failed_initialization( @@ -149,31 +149,31 @@ def test_log_status_failed_initialization( check_file_for_messages(False, self.id(), MESSAGE2) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._STATUS_LOG_PATH", + "azure.monitor.opentelemetry._diagnostics.status_logger._STATUS_LOG_PATH", TEST_LOGGER_PATH, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger.VERSION", TEST_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.status_logger._IS_DIAGNOSTICS_ENABLED", True, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.getpid", + "azure.monitor.opentelemetry._diagnostics.status_logger.getpid", return_value=TEST_PID, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_log_status_no_reason(self, mock_getpid, mock_get_ikey): @@ -182,31 +182,31 @@ def test_log_status_no_reason(self, mock_getpid, mock_get_ikey): check_file_for_messages(True, self.id()) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._STATUS_LOG_PATH", + "azure.monitor.opentelemetry._diagnostics.status_logger._STATUS_LOG_PATH", TEST_LOGGER_PATH, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger.VERSION", TEST_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.status_logger._IS_DIAGNOSTICS_ENABLED", False, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.getpid", + "azure.monitor.opentelemetry._diagnostics.status_logger.getpid", return_value=TEST_PID, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_disabled_log_status_success(self, mock_getpid, mock_get_ikey): @@ -215,31 +215,31 @@ def test_disabled_log_status_success(self, mock_getpid, mock_get_ikey): check_file_is_empty(self.id()) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._STATUS_LOG_PATH", + "azure.monitor.opentelemetry._diagnostics.status_logger._STATUS_LOG_PATH", TEST_LOGGER_PATH, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger.VERSION", TEST_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.status_logger._IS_DIAGNOSTICS_ENABLED", False, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.getpid", + "azure.monitor.opentelemetry._diagnostics.status_logger.getpid", return_value=TEST_PID, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_disabled_log_status_failed_initialization( @@ -250,31 +250,31 @@ def test_disabled_log_status_failed_initialization( check_file_is_empty(self.id()) # @patch( - # "azure.monitor.opentelemetry.diagnostics._status_logger._STATUS_LOG_PATH", + # "azure.monitor.opentelemetry._diagnostics.status_logger._STATUS_LOG_PATH", # TEST_LOGGER_PATH, # ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._get_customer_ikey_from_env_var", + "azure.monitor.opentelemetry._diagnostics.status_logger._get_customer_ikey_from_env_var", return_value=TEST_CUSTOMER_IKEY, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._EXTENSION_VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger._EXTENSION_VERSION", TEST_EXTENSION_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.VERSION", + "azure.monitor.opentelemetry._diagnostics.status_logger.VERSION", TEST_VERSION, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._IS_DIAGNOSTICS_ENABLED", + "azure.monitor.opentelemetry._diagnostics.status_logger._IS_DIAGNOSTICS_ENABLED", False, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger.getpid", + "azure.monitor.opentelemetry._diagnostics.status_logger.getpid", return_value=TEST_PID, ) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_disabled_log_status_no_reason(self, mock_getpid, mock_get_ikey): @@ -283,7 +283,7 @@ def test_disabled_log_status_no_reason(self, mock_getpid, mock_get_ikey): check_file_is_empty(self.id()) @patch( - "azure.monitor.opentelemetry.diagnostics._status_logger._MACHINE_NAME", + "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME", TEST_MACHINE_NAME, ) def test_get_status_logger_file_name(self): From 17e6018de0b4a8ca3b6c59bc2b3c66925c018c24 Mon Sep 17 00:00:00 2001 From: antisch Date: Mon, 4 Sep 2023 08:46:58 +1200 Subject: [PATCH 2/3] Updated docstring --- .../azure/monitor/opentelemetry/_configure.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index 8c0389e32d5d..47f645ab561e 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -56,18 +56,18 @@ def configure_azure_monitor(**kwargs) -> None: - """ - This function works as a configuration layer that allows the + """This function works as a configuration layer that allows the end user to configure OpenTelemetry and Azure monitor components. The configuration can be done via arguments passed to this function. + :keyword str connection_string: Connection string for your Application Insights resource. - :keyword ManagedIdentityCredential/ClientSecretCredential credential: Token credential, such as - ManagedIdentityCredential or ClientSecretCredential, used for Azure Active Directory (AAD) authentication. Defaults - to None. - :keyword bool disable_offline_storage: Boolean value to determine whether to disable storing failed telemetry - records for retry. Defaults to `False`. + :keyword credential: Token credential, such as `ManagedIdentityCredential` or `ClientSecretCredential`, + used for Azure Active Directory (AAD) authentication. Defaults to `None`. + :paramtype credential: ~azure.core.credentials.TokenCredential + :keyword bool disable_offline_storage: Boolean value to determine whether to disable storing failed + telemetry records for retry. Defaults to `False`. :keyword str storage_directory: Storage directory in which to store retry files. Defaults to - `/Microsoft/AzureMonitor/opentelemetry-python-`. + `/Microsoft/AzureMonitor/opentelemetry-python-`. :rtype: None """ From c538ff0b2a3275a80acf70a5ace6dd1686dc2f18 Mon Sep 17 00:00:00 2001 From: antisch Date: Wed, 6 Sep 2023 06:51:52 +1200 Subject: [PATCH 3/3] Optional credential --- .../azure/monitor/opentelemetry/_configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index 47f645ab561e..53c5d6b3da7a 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -63,7 +63,7 @@ def configure_azure_monitor(**kwargs) -> None: :keyword str connection_string: Connection string for your Application Insights resource. :keyword credential: Token credential, such as `ManagedIdentityCredential` or `ClientSecretCredential`, used for Azure Active Directory (AAD) authentication. Defaults to `None`. - :paramtype credential: ~azure.core.credentials.TokenCredential + :paramtype credential: ~azure.core.credentials.TokenCredential or None :keyword bool disable_offline_storage: Boolean value to determine whether to disable storing failed telemetry records for retry. Defaults to `False`. :keyword str storage_directory: Storage directory in which to store retry files. Defaults to