-
Notifications
You must be signed in to change notification settings - Fork 519
Labels
Description
The agent-framework package OTEL setup means that it requires Azure Monitor connection strings to be set in the environment variables or settings.
I'm trying to use the Python app with the Aspire dashboard, which uses the OTLP exporter to a local endpoint. I use OTEL auto-instrumentation to pickup the OTLP environment variables that Aspire sets, but it's colliding with Azure Monitor.
This is a reproducible sample:
from opentelemetry.instrumentation.auto_instrumentation import initialize
initialize()
...
def main():
"""Launch the spam detection workflow in DevUI."""
from agent_framework.devui import serve
port = os.environ.get("PORT", 8090)
# Launch server with the workflow
serve(entities=[workflow], port=int(port), auto_open=True)
if __name__ == "__main__":
main()
I'm not using Azure Monitor in this application, my pyproject.toml
is:
[project]
name = "agent-framework-demo"
version = "0.1.0"
description = "FastAPI project"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"agent-framework==1.0.0b251007",
"azure-ai-agents==1.2.0b5",
"opentelemetry-instrumentation-fastapi",
"opentelemetry-exporter-otlp",
"opentelemetry-distro",
]
OTEL fails to initialize:
Failed to auto initialize OpenTelemetry
Traceback (most recent call last):
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\instrumentation\auto_instrumentation\__init__.py", line 165, in initialize
_load_configurators()
~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\instrumentation\auto_instrumentation\_load.py", line 184, in _load_configurators
raise exc
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\instrumentation\auto_instrumentation\_load.py", line 171, in _load_configurators
entry_point.load()().configure(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auto_instrumentation_version=__version__
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
) # type: ignore
^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\sdk\_configuration\__init__.py", line 498, in configure
self._configure(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\azure\monitor\opentelemetry\_autoinstrumentation\configurator.py", line 68, in _configure
raise e
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\azure\monitor\opentelemetry\_autoinstrumentation\configurator.py", line 58, in _configure
super()._configure(**kwargs)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\sdk\_configuration\__init__.py", line 514, in _configure
_initialize_components(**kwargs)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\sdk\_configuration\__init__.py", line 448, in _initialize_components
_init_tracing(
~~~~~~~~~~~~~^
exporters=span_exporters,
^^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
exporter_args_map=exporter_args_map,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\opentelemetry\sdk\_configuration\__init__.py", line 223, in _init_tracing
BatchSpanProcessor(exporter_class(**exporter_args))
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\azure\monitor\opentelemetry\exporter\export\trace\_exporter.py", line 108, in __init__
super().__init__(**kwargs)
~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\azure\monitor\opentelemetry\exporter\export\_base.py", line 108, in __init__
parsed_connection_string = ConnectionStringParser(kwargs.get("connection_string"))
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\azure\monitor\opentelemetry\exporter\_connection_string_parser.py", line 42, in __init__
self._validate_instrumentation_key()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\anthonyshaw\source\repos\AspireFastAPI\AspireFastAPI.AppHost\webapp\.venv\Lib\site-packages\azure\monitor\opentelemetry\exporter\_connection_string_parser.py", line 103, in _validate_instrumentation_key
raise ValueError("Instrumentation key cannot be none or empty.")