Pass `IServiceProvider` to the `applicationInsights` lambda in order to make it more effective
ysmoradi opened this issue · comments
Instead of
builder.Services.AddBlazorApplicationInsights(config =>
{
config.ConnectionString = "{Insert Connection String}";
},
async applicationInsights =>
{
var telemetryItem = new TelemetryItem()
{
Tags = new Dictionary<string, object?>()
{
{ "ai.cloud.role", "SPA" },
{ "ai.cloud.roleInstance", "Blazor Wasm" },
}
};
await applicationInsights.AddTelemetryInitializer(telemetryItem);
});
We could have:
builder.Services.AddBlazorApplicationInsights(config =>
{
config.ConnectionString = "{Insert Connection String}";
},
async (serviceProvider, applicationInsights) =>
{
var telemetryItem = new TelemetryItem()
{
Tags = new Dictionary<string, object?>()
{
{ "ai.cloud.role", "SPA" },
{ "ai.cloud.roleInstance", "Blazor Wasm" },
}
};
await applicationInsights.AddTelemetryInitializer(telemetryItem);
});