-
Notifications
You must be signed in to change notification settings - Fork 171
feat: improve Application Insights logging and telemetry handling #753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
216160a
a8b2519
18dfa2f
ada9183
8f12f49
0b31416
b6c3775
d812896
3a702f9
8da20ea
b3eb6ba
2a02601
3bede32
8cfe8ef
bef888a
6badeb4
e9af432
2a8abee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||
|
|
@@ -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") | ||||||||||||||||||
|
||||||||||||||||||
| 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") |
There was a problem hiding this comment.
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_STRINGand passes it asconnection_string. Please renameinstrumentation_keyto something likeappinsights_connection_stringand 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).