aspnet / Templates

This repo is OBSOLETE - please see the README file for information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Removing ApplicationInsights (AI) from template generated project not straightforward.

Rick-Anderson opened this issue · comments

Microsoft Visual Studio Enterprise 2017 RC3

It's a bit confusing trying to remove AI from a simple project. Removing the two AI references in Views\Shared_Layout.cshtml are not obvious. When you remove

<ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
  </ItemGroup>

The compiler takes you to .UseApplicationInsights() in Main().

After removing that you get this stack trace (cut off)

An unhandled exception occurred while processing the request.

InvalidOperationException: No service for type 'Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet' has been registered.
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)

Stack Query Cookies Headers
InvalidOperationException: No service for type 'Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet' has been registered.
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator+<>c__DisplayClass16_0.<CreateActivateInfo>b__1(ViewContext context)
Microsoft.Extensions.Internal.PropertyActivator.Activate(object instance, TContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator.Activate(IRazorPage page, ViewContext context)

I was expecting to find AI registered in ConfigureServices()

Should I create a SO Q&A in for those who run into this?

PS
When I launch a template generate new web app (with all the defaults) I get this very confusing dialog
image

There is not a "no thanks" button.

@mlorbetske
We should follow up with the Application Insights owners for both aspects of this issue since there now is no longer an option to opt out of AI.

There really should be a checkbox in the project template dialog which allows you to disable Application Insights. This used to exist (at least in VS 2015). I'd recommend putting it near the "Enable Docker Support" checkbox. For enterprise customers with an alternative APM solution, this will be an annoyance.

It would be nice if 1) this is a checkbox, and 2) the checkbox is hidden if your install of VS has no azure components installed. You should be able to detect if the developer tends to use azure or not, and if not completely hide this all together.

I agree with everything here. I'll even say the checkbox should be unchecked by default. Every template I use includes AI and BrowserLink and I barely even have an idea what they are. I don't want to have two unnecessary packages in all my projects.

The direction we're heading is that AI won't be included in the new templates & can be turned on via a "platform lightup" - effectively that it'll be able to be turned on/off without code changes. At the moment, I'm not certain what the plan is for .NET framework and .NET Core 1.x templates in that regard though as the platform lightup is, I believe 2.0 specific.

It's super important... now it's looks like noisy spam.

Is BrowserLink is a component of ApplicationInsights? Would this be disabled by default as well with the "platform lightup" feature?

Ref: aspnet/Mvc#5999

@shravan2x BrowserLink is not a component of AI. Adding @jodavis and @madskristensen to speak to plans in that space.

I just spent 30 ,its working this out. IMHO Application Insights should not be included by default.

Closing given this is fixed in 2.x