@@ -1205,15 +1205,17 @@ def emit_eval_result_events_to_app_insights(app_insights_config: AppInsightsConf
12051205 # Configure OpenTelemetry logging with anonymized Resource attributes
12061206 from opentelemetry .sdk .resources import Resource
12071207 from opentelemetry .semconv .resource import ResourceAttributes
1208-
1208+
12091209 # Create a resource with minimal attributes to prevent sensitive data collection
12101210 # SERVICE_INSTANCE_ID maps to cloud_RoleInstance in Azure Monitor and prevents
12111211 # Azure Monitor from auto-detecting the device hostname
1212- anonymized_resource = Resource .create ({
1213- ResourceAttributes .SERVICE_NAME : "unknown" ,
1214- ResourceAttributes .SERVICE_INSTANCE_ID : "unknown" ,
1215- })
1216-
1212+ anonymized_resource = Resource .create (
1213+ {
1214+ ResourceAttributes .SERVICE_NAME : "unknown" ,
1215+ ResourceAttributes .SERVICE_INSTANCE_ID : "unknown" ,
1216+ }
1217+ )
1218+
12171219 logger_provider = LoggerProvider (resource = anonymized_resource )
12181220 _logs .set_logger_provider (logger_provider )
12191221
@@ -1226,10 +1228,10 @@ def emit_eval_result_events_to_app_insights(app_insights_config: AppInsightsConf
12261228 # Create a logger from OUR configured logger_provider (not the global one)
12271229 # This ensures the logger uses our anonymized resource
12281230 otel_logger = logger_provider .get_logger (__name__ )
1229-
1231+
12301232 # Initialize base log attributes with extra_attributes if present, otherwise empty dict
12311233 base_log_attributes = app_insights_config .get ("extra_attributes" , {})
1232-
1234+
12331235 # Add AppInsights config attributes with proper semantic convention mappings
12341236 if "run_type" in app_insights_config :
12351237 base_log_attributes ["gen_ai.evaluation.azure_ai_type" ] = str (app_insights_config ["run_type" ])
@@ -1243,7 +1245,7 @@ def emit_eval_result_events_to_app_insights(app_insights_config: AppInsightsConf
12431245 for result in results :
12441246 # Create a copy of base attributes for this result's events
12451247 log_attributes = base_log_attributes .copy ()
1246-
1248+
12471249 _log_events_to_app_insights (
12481250 otel_logger = otel_logger ,
12491251 events = result ["results" ],
0 commit comments