From 88a4fdba429ad8cc043d39a6d2c3a88f6ec4082c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Sat, 17 Aug 2024 13:02:02 +0200 Subject: [PATCH] fix: Make App Insights optional at launch --- app/helpers/monitoring.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/helpers/monitoring.py b/app/helpers/monitoring.py index 22e487d..2114cb3 100644 --- a/app/helpers/monitoring.py +++ b/app/helpers/monitoring.py @@ -9,10 +9,12 @@ # Azure Application Insights APPINSIGHTS_CONNECTION_STRING = env.get("APPLICATIONINSIGHTS_CONNECTION_STRING", None) -if not APPINSIGHTS_CONNECTION_STRING: - raise ValueError("APPLICATIONINSIGHTS_CONNECTION_STRING is not set") -# OpenTelemetry -configure_azure_monitor() # Configure Azure Application Insights exporter -AioHttpClientInstrumentor().instrument() # Instrument aiohttp -HTTPXClientInstrumentor().instrument() # Instrument httpx +if not APPINSIGHTS_CONNECTION_STRING: + # We don't raise an error, that feature must be optional + print("Azure Application Insights monitoring is disabled, set APPLICATIONINSIGHTS_CONNECTION_STRING to enable.") +else: + # OpenTelemetry + configure_azure_monitor() # Configure Azure Application Insights exporter + AioHttpClientInstrumentor().instrument() # Instrument aiohttp + HTTPXClientInstrumentor().instrument() # Instrument httpx