Skip to content

Commit

Permalink
fix: Make App Insights optional at launch
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Aug 17, 2024
1 parent e788b9f commit 88a4fdb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/helpers/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 88a4fdb

Please sign in to comment.