Skip to content

Asp.Net Core WebApi Telemetry only works when key specified in config #92

@Adebeer

Description

@Adebeer

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 HttpDependenciesParsingTelemetryInitializer and OperationCorrelationTelemetryInitializer and registering those as ITelemetryInitializer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions