Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Adebeer opened this issue Nov 17, 2018 · 3 comments
Open

Comments

@Adebeer
Copy link

Adebeer commented Nov 17, 2018

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

@Adebeer
Copy link
Author

Adebeer commented Nov 18, 2018

Unfortunately it seems the situation is even worse than I thought.
So I updated all the configuration files to point to a new AI instance in azure - but no telemetry got sent to it...
until I used VS studio to reconfigure all AI keys - and it seem to update these settings in the csproj files with the new AI keys:

<ApplicationInsightsResourceId></ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId></ApplicationInsightsAnnotationResourceId>

Wow - does AI really not support configuration via code?? I'm hoping it's not as dire as it looks to me atm...

@yantang-msft
Copy link
Contributor

AI's configuration scenario is different for each platform, e.g., console, AspNet, AspNet Core.
In your case, please refer this for configurations.
As far as I know, the configuration story for AspNet core is not as mature as AspNet. But it does support the IKey.

@Adebeer
Copy link
Author

Adebeer commented Nov 18, 2018

Thank you @yangg-msft - I haven't come across this resource before. I need to do a bit more tweaking to my code but it looks promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants