Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions content-gen/src/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from services.blob_service import get_blob_service
from services.title_service import get_title_service
from api.admin import admin_bp
from azure.monitor.opentelemetry import configure_azure_monitor

# In-memory task storage for generation tasks
# In production, this should be replaced with Redis or similar
Expand All @@ -37,6 +38,16 @@
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.WARNING)
logger = logging.getLogger(__name__)

# Check if the Application Insights Instrumentation Key is set in the environment variables
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if instrumentation_key:
# Configure Application Insights if the Instrumentation Key is found
configure_azure_monitor(connection_string=instrumentation_key)
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments/log messages and variable name refer to an "Instrumentation Key", but the code is reading APPLICATIONINSIGHTS_CONNECTION_STRING and passes it as connection_string. Please rename instrumentation_key to something like appinsights_connection_string and update the comments/messages to consistently refer to a connection string (or change the env var if you truly intend to use an instrumentation key).

Suggested change
# Check if the Application Insights Instrumentation Key is set in the environment variables
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if instrumentation_key:
# Configure Application Insights if the Instrumentation Key is found
configure_azure_monitor(connection_string=instrumentation_key)
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
# Check if the Application Insights connection string is set in the environment variables
appinsights_connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if appinsights_connection_string:
# Configure Application Insights if the connection string is found
configure_azure_monitor(connection_string=appinsights_connection_string)
logging.info("Application Insights configured with the provided connection string")
else:
# Log a warning if the connection string is not found
logging.warning("No Application Insights connection string found. Skipping configuration")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file defines a module logger (logger = logging.getLogger(__name__)), but these new lines log via the root logging module. Please use the module logger (logger.info / logger.warning) so log records have the correct logger name and can be filtered/structured consistently with the rest of the file.

Suggested change
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
logger.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logger.warning("No Application Insights Instrumentation Key found. Skipping configuration")

Copilot uses AI. Check for mistakes.

# Create Quart app
app = Quart(__name__)
app = cors(app, allow_origin="*")
Expand Down
Loading