File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424from services .blob_service import get_blob_service
2525from services .title_service import get_title_service
2626from api .admin import admin_bp
27+ from azure .monitor .opentelemetry import configure_azure_monitor
2728
2829# In-memory task storage for generation tasks
2930# In production, this should be replaced with Redis or similar
3738logging .getLogger ("azure.core.pipeline.policies.http_logging_policy" ).setLevel (logging .WARNING )
3839logger = logging .getLogger (__name__ )
3940
41+ # Check if the Application Insights Instrumentation Key is set in the environment variables
42+ instrumentation_key = os .getenv ("APPLICATIONINSIGHTS_CONNECTION_STRING" )
43+ if instrumentation_key :
44+ # Configure Application Insights if the Instrumentation Key is found
45+ configure_azure_monitor (connection_string = instrumentation_key )
46+ logging .info ("Application Insights configured with the provided Instrumentation Key" )
47+ else :
48+ # Log a warning if the Instrumentation Key is not found
49+ logging .warning ("No Application Insights Instrumentation Key found. Skipping configuration" )
50+
4051# Create Quart app
4152app = Quart (__name__ )
4253app = cors (app , allow_origin = "*" )
You can’t perform that action at this time.
0 commit comments