Skip to content

Commit 852ff81

Browse files
Merge pull request #221 from microsoft/PSL-US-18215
fix: Application Insights updating telemetry
2 parents 56d9c9b + 775efab commit 852ff81

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/backend/app_kernel.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# app_kernel.py
22
import asyncio
33
import logging
4+
import os
45
import uuid
56
from typing import Dict, List, Optional
67

@@ -9,6 +10,7 @@
910
from auth.auth_utils import get_authenticated_user_details
1011

1112
# Azure monitoring
13+
from azure.monitor.opentelemetry import configure_azure_monitor
1214
from config_kernel import Config
1315
from event_utils import track_event_if_configured
1416

@@ -32,19 +34,19 @@
3234
# Updated import for KernelArguments
3335
from utils_kernel import initialize_runtime_and_context, rai_success
3436

35-
# # Check if the Application Insights Instrumentation Key is set in the environment variables
36-
# connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
37-
# if connection_string:
38-
# # Configure Application Insights if the Instrumentation Key is found
39-
# configure_azure_monitor(connection_string=connection_string)
40-
# logging.info(
41-
# "Application Insights configured with the provided Instrumentation Key"
42-
# )
43-
# else:
44-
# # Log a warning if the Instrumentation Key is not found
45-
# logging.warning(
46-
# "No Application Insights Instrumentation Key found. Skipping configuration"
47-
# )
37+
# Check if the Application Insights Instrumentation Key is set in the environment variables
38+
connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
39+
if connection_string:
40+
# Configure Application Insights if the Instrumentation Key is found
41+
configure_azure_monitor(connection_string=connection_string)
42+
logging.info(
43+
"Application Insights configured with the provided Instrumentation Key"
44+
)
45+
else:
46+
# Log a warning if the Instrumentation Key is not found
47+
logging.warning(
48+
"No Application Insights Instrumentation Key found. Skipping configuration"
49+
)
4850

4951
# Configure logging
5052
logging.basicConfig(level=logging.INFO)

0 commit comments

Comments
 (0)