-
Notifications
You must be signed in to change notification settings - Fork 27
Asp.Net Core WebApi Telemetry only works when key specified in config #92
Description
Hi
When specifying AI key purely via code, I'm having trouble getting my Stateless Asp.Net Core 2.1 Service fabric application to send telemetry to AI.
Specifically, when I enter the AI key in appsettings.json file, everything works as expected - I can see HTTP request with all dependency tracking in place for API->Remoting Service -> SQL Server
If however, I remove the instrumentation key (from all projects) - everything BUT the HTTP/webapi telemetry shows up. It also doesn't show up in the AI Live Metrics page.
Here's what I've tried:
- In first line of Program.cs - set:
TelemetryConfiguration.Active.InstrumentationKey = key; - As per docs, I've added the following:
.AddSingleton<ITelemetryInitializer>(serviceProvider =>
FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(aspNetCoreServiceContext))
.AddSingleton<ITelemetryModule>(serviceProvider =>
{
var module = new ServiceRemotingRequestTrackingTelemetryModule();
module.Initialize(TelemetryConfiguration.Active); // even tried this to make sure it's initialized
return module;
})
.AddSingleton<ITelemetryModule>(serviceProvider =>
{
var module = new ServiceRemotingDependencyTrackingTelemetryModule();
module.Initialize(TelemetryConfiguration.Active); // even tried this to make sure it's initialized
return module;
});
- I've also tried explicitly adding
HttpDependenciesParsingTelemetryInitializerandOperationCorrelationTelemetryInitializerand registering those asITelemetryInitializer
What am I missing? The reason I want the key set via config is because this SF app has multiple environments and I would like to use multiple AI keys (and no key for Local dev clusters)
Interestingly - the Remoting call does have Operation info of the originating web api call (e.g. "POST Login/Post"). Hence, as far as I can tell, there is no telemetry being sent for the Web API's http/requests
Any help would be greatly appreciated