Код: Выделить всё
azure-monitor-opentelemetry==1.6.2
Однако, когда я развертываю свое веб-приложение в Службе приложений Azure и когда кто-то обращается к веб-приложению, мое приложение регистрирует следующее исключение в аналитике приложения:
Не удалось получить ресурс от поставщика Tracer: объект «ProxyTracerProvider» не имеет атрибута «resource»< /strong>
Код: Выделить всё
Traceback (most recent call last):
File "/tmp/8dcd22e385c2da5/antenv/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py", line 91, in export
resource = tracer_provider.resource # type: ignore
Я реализовал azure- монитор-opentelemetry в моем приложении просто следующим образом:
appopentelemetry.py:
Код: Выделить всё
from azure.monitor.opentelemetry import configure_azure_monitor
from models.environmentmanager.environmentmanager import EnvironmentManager
def azure_monitoring_open_telemetry():
environment_manager = EnvironmentManager()
connection_string = environment_manager.get_connection_string() # The app insight connection string
return configure_azure_monitor(
connection_string=connection_string,
enable_live_metrics=True,
)
Код: Выделить всё
...imports...
environment_manager = EnvironmentManager()
# This should be executed if the environment is not local, this is set in .env if ran locally
# and set in environment variables of the app service on Azure when deployed
if not environment_manager.get_is_local():
from functions.app.appopentelemetry import azure_monitoring_open_telemetry
azure_monitoring_open_telemetry()
...
app = Dash(__name__, use_pages=True, external_stylesheets=stylesheets)
...
app.layout = dmc.MantineProvider(...)
if __name__ == '__main__':
app.run(debug=True, port=8000)
Подробнее здесь: https://stackoverflow.com/questions/789 ... hon-app-de