Description
Package Name: azure-monitor-opentelemetry
Package Version: 1.6.1
Operating System: Linux
Python Version: 3.11
Describe the bug:
I am deploying a python based web-app on Azure App service. This is docker image which is being pulled from Azure container registry.
The problem is coming from inside the Azure Monitor OpenTelmetry SDK. The sdk creates log files for diagnostic logging within the following directory : /var/log/applicationinsights/
(for linux based web apps). This can be seen from the following code from the above sdk. This File path has been hardcoded in the sdk and is not configurable. I start the app using an app_user, which has access to the app related volumes in the container but not to the above directory.
if not exists(_DIAGNOSTIC_LOG_PATH):
makedirs(_DIAGNOSTIC_LOG_PATH)
f_handler = logging.FileHandler(
join(
_DIAGNOSTIC_LOG_PATH, _DIAGNOSTIC_LOGGER_FILE_NAME
)
)
This was added as part of the following bug: Adding diagnostic warning when distro detects RP attach (#34971)
Due to this the App does not start with the following stacktrace:
2024-10-25T04:33:34.877284066Z File "/usr/src/app/doc_generator_api/main.py", line 19, in <module>
2024-10-25T04:33:34.877309466Z configure_azure_telemetry(option="basic")
2024-10-25T04:33:34.877361967Z File "/usr/src/app/doc_generator_api/dependencies/instrumentation.py", line 11, in configure_azure_telemetry
2024-10-25T04:33:34.877378367Z configure_basic_azure_monitor()
2024-10-25T04:33:34.877383767Z File "/usr/src/app/doc_generator_api/dependencies/instrumentation.py", line 25, in configure_basic_azure_monitor
2024-10-25T04:33:34.878324584Z configure_azure_monitor(
2024-10-25T04:33:34.879013896Z File "/agents/python/azure/monitor/opentelemetry/_configure.py", line 98, in configure_azure_monitor
2024-10-25T04:33:34.879018996Z _send_attach_warning()
2024-10-25T04:33:34.879022896Z File "/agents/python/azure/monitor/opentelemetry/_configure.py", line 222, in _send_attach_warning
2024-10-25T04:33:34.879026897Z AzureDiagnosticLogging.warning(
2024-10-25T04:33:34.879030297Z File "/agents/python/azure/monitor/opentelemetry/_diagnostics/diagnostic_logging.py", line 87, in warning
2024-10-25T04:33:34.879034197Z AzureDiagnosticLogging._initialize()
2024-10-25T04:33:34.879037997Z File "/agents/python/azure/monitor/opentelemetry/_diagnostics/diagnostic_logging.py", line 68, in _initialize
2024-10-25T04:33:34.879041897Z f_handler = logging.FileHandler(
2024-10-25T04:33:34.879883312Z ^^^^^^^^^^^^^^^^^^^^
2024-10-25T04:33:34.879896112Z File "/opt/conda/lib/python3.11/logging/__init__.py", line 1181, in __init__
2024-10-25T04:33:34.879905312Z StreamHandler.__init__(self, self._open())
2024-10-25T04:33:34.879910112Z ^^^^^^^^^^^^
2024-10-25T04:33:34.879914512Z File "/opt/conda/lib/python3.11/logging/__init__.py", line 1213, in _open
2024-10-25T04:33:34.879919112Z return open_func(self.baseFilename, self.mode,
2024-10-25T04:33:34.879923612Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-25T04:33:34.879928513Z PermissionError: [Errno 13] Permission denied: '/var/log/applicationinsights/applicationinsights-extension.log'
Expected behavior: There should be a way to disable diagnostic logging in Azure monitor.