Skip to content

ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' in v1.8.2 #44237

@pietervdheijden

Description

@pietervdheijden
  • Package Name: azure-monitor-opentelemetry
  • Package Version: 1.8.2
  • Operating System: Ubuntu
  • Python Version: 3.11

Describe the bug
After upgrading our Python app to azure-monitor-opentelemetry version 1.8.2, it no longer starts. The behavior looks similar to what’s described in #41996. As a temporary workaround, we downgraded the package to 1.6.13, following the suggestion in that thread. However, that’s not a sustainable long-term fix, so I’m opening this issue to help get the problem addressed in the latest release.

Stack trace:

ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/usr/local/lib/python3.11/site-packages/opentelemetry/sdk/_logs/init.py)
Process SpawnProcess-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/local/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 78, in subprocess_started
target(sockets=sockets)
File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 62, in run
return asyncio.run(self.serve(sockets=sockets))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve
config.load()
File "/usr/local/lib/python3.11/site-packages/uvicorn/config.py", line 458, in load
self.loaded_app = import_from_string(self.app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/app/src/app.py", line 7, in
from *** import ***
File "/usr/local/lib/python3.11/site-packages/***.py", line 19, in
from ..utils.logger import get_logger
File "/usr/local/lib/python3.11/site-packages/***.py", line 267, in
logger = get_logger(name)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/***.py", line 121, in get_logger
return LoggerFactory().get(logger_name)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/***.py", line 5, in call
cls._instances[cls] = super(Singleton, cls).call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/***.py", line 83, in init
from azure.monitor.opentelemetry import configure_azure_monitor
File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/init.py", line 7, in
from azure.monitor.opentelemetry._configure import configure_azure_monitor
File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/_configure.py", line 33, in
from azure.monitor.opentelemetry._constants import (
File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/_constants.py", line 7, in
from azure.monitor.opentelemetry.exporter._constants import ( # pylint: disable=import-error,no-name-in-module
File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/exporter/init.py", line 7, in
from azure.monitor.opentelemetry.exporter.export.logs._exporter import AzureMonitorLogExporter
File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/exporter/export/logs/_exporter.py", line 14, in
from opentelemetry.sdk._logs import LogData
ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/usr/local/lib/python3.11/site-packages/opentelemetry/sdk/_logs/init.py)

Metadata

Metadata

Assignees

Labels

MonitorMonitor, Monitor Ingestion, Monitor QueryService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions