Issues with custom telemetry initializers in ASP.NET Core 6 not capturing specific properties
I'm currently working on an ASP.NET Core 6 application using Azure Application Insights for telemetry. I've implemented a custom telemetry initializer to enrich my telemetry data with additional properties, but I'm encountering an issue where only some of the properties are being logged, while others appear to be missing. Here's the custom telemetry initializer I created: ```csharp public class CustomTelemetryInitializer : ITelemetryInitializer { public void Initialize(ITelemetry telemetry) { if (telemetry is RequestTelemetry requestTelemetry) { requestTelemetry.Properties["UserRole"] = "Admin"; requestTelemetry.Properties["CorrelationId"] = Guid.NewGuid().ToString(); } } } ``` I registered this initializer in the `Startup.cs` file like so: ```csharp public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(); services.AddSingleton<ITelemetryInitializer, CustomTelemetryInitializer>(); } ``` I've verified that the initializer is being called because I see the "UserRole" property in the Application Insights portal. However, the "CorrelationId" seems to be absent from the telemetry logs. I've tried adding some logging within the `Initialize` method to confirm that the code is executing, and it is. Additionally, I checked the Application Insights configuration in `appsettings.json`, ensuring that telemetry is not being filtered out: ```json { "ApplicationInsights": { "InstrumentationKey": "YOUR_INSTRUMENTATION_KEY_HERE", "TelemetryChannel": { "DeveloperMode": true } } } ``` I'm also aware that some properties might get overridden by the default telemetry context. Could that be the reason for the missing property? I've read through the documentation, but I still can't figure out why "CorrelationId" is not being captured correctly. Any insights on what could be going wrong or how to troubleshoot this further would be greatly appreciated!