From d12ed18231f2c1b0ee12079709dc06a4fe714362 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Wed, 8 Feb 2023 14:59:04 -0800 Subject: [PATCH 1/2] Removed old log_diagnostic_error calls from configurator --- CHANGELOG.md | 2 ++ .../monitor/opentelemetry/distro/configurator.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9fc96be..643358ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ ([#241](https://github.com/microsoft/ApplicationInsights-Python/pull/241)) - Defaulting logging env var for auto-instrumentation. Added logging samples. ([#240](https://github.com/microsoft/ApplicationInsights-Python/pull/240)) +- Removed old log_diagnostic_error calls from configurator + ([#242](https://github.com/microsoft/ApplicationInsights-Python/pull/242)) ## [1.0.0b8](https://github.com/microsoft/ApplicationInsights-Python/releases/tag/v1.0.0b8) - 2022-09-26 diff --git a/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py b/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py index 3593471c..bd4d2ea4 100644 --- a/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py +++ b/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py @@ -5,23 +5,26 @@ # -------------------------------------------------------------------------- +import logging + from azure.monitor.opentelemetry.distro._diagnostics._diagnostic_logging import ( AzureDiagnosticLogging, ) from opentelemetry.sdk._configuration import _OTelSDKConfigurator +_logger = logging.getLogger(__name__) + class AzureMonitorConfigurator(_OTelSDKConfigurator): def _configure(self, **kwargs): try: + AzureDiagnosticLogging.enable(_logger) super()._configure(**kwargs) except ValueError as e: - AzureDiagnosticLogging.log_diagnostic_error( + _logger.error( f"The components failed to initialize due to a ValueError: {e}" ) raise e except Exception as e: - AzureDiagnosticLogging.log_diagnostic_error( - f"The components failed to initialize: {e}" - ) + _logger.error(f"The components failed to initialize: {e}") raise e From fb4cdb620a230b1c720932ec00246b0791059854 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Wed, 8 Feb 2023 15:18:08 -0800 Subject: [PATCH 2/2] Made configurator error messages more descriptive --- .../azure/monitor/opentelemetry/distro/configurator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py b/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py index bd4d2ea4..cd83f70f 100644 --- a/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py +++ b/azure-monitor-opentelemetry-distro/azure/monitor/opentelemetry/distro/configurator.py @@ -22,9 +22,11 @@ def _configure(self, **kwargs): super()._configure(**kwargs) except ValueError as e: _logger.error( - f"The components failed to initialize due to a ValueError: {e}" + f"Azure Monitor Configurator failed during configuration due to a ValueError: {e}" ) raise e except Exception as e: - _logger.error(f"The components failed to initialize: {e}") + _logger.error( + f"Azure Monitor Configurator failed during configuration: {e}" + ) raise e