-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
How to disable application insights in asp.net core 2.0? #2051
Comments
After further investigation this appears to be tied to visual studio as debugging outside of VS (using vscode or just running on the command line) does not show these messages. To help make sure everyone is on the same page, here is the output I observe in the debug window in VS after one HTTP request.
|
I concur, it actually hangs my VS whenever I try to debug EF stuff (which logs a ton of stuff). |
Same issue here, Doing some memory profiling to make sure I have no leaks, and noticing a lot of stuff being added to an application insights As far as I knew, I had no insights running at all (no NuGet package added) Just like Trcx528 I see output into my debug console along the lines of: How do we disable it? |
Same issue, doing anything is taking forever... |
ApplicationInsights is being dynamically injected. One way to disable this is to set the environment variable ASPNETCORE_preventHostingStartup to "true" in your project launch settings. |
@Tratcher can you give more details? From the linked commit, I can't figure out how to modify my |
Any reason why these are on by default? Are you collecting usage information? |
Visual Studio 2017 has the "Developer Analytics Tools" extension installed as a strong dependency of asp.net - when you try to uninstall, it will uninstall your web development and dotnet core tools, too (omg). I disabled this extension - no effect, the annyoing debug messages appear by default (arg). The Microsoft.AspNetCore.All meta nuget package has a dependency on application insights package, so it is installed by default (arg). If you publish your app using a specific RID, the application insights dlls are copied, too. The complicated, undocumented way of opt-out is correctly given by @Tratcher: in VS, on your web project open Properties >
Alternatively, you can right click your web project > Properties > Debug and add the mystic environment variable there. Grrr. This should be opt-in or simple opt-out! |
Thanks! I discovered this only because of the unconfigured logger. Can someone from MS please confirm if @nzain's workaround disables Application Insights, or just hides the logs? I don't want AI at all. |
+1 |
1 similar comment
+1 |
@Trcx528 Please consider changing the title to
...so it gets more attention? This problem is still with us. If it has "preview" in the title it might get ignored because the final version was recently released. And thanks for your post, and for alerting all of us. |
|
I concur, this is really odd behaviour. I know it's nice that you are able to just "enable" Application Insights through Azure without having to even reference it in your project, but I think the cost is too high from a framework perspective, if this is how it is done. |
We're going to add some ui to disable AI injection when running in VS. We should have added it in the first place (it was an oversight). The workaround that @Tratcher suggested works fine but will disable the light up feature completely so it can affect more than insights. For example, the ASP.NET Core IIS Module lights up the IISIntegration package when it launches the process https://github.com/aspnet/AspNetCoreModule/blob/002c8b9bc9a86cd3b4308e62c1f70ea625cbaae2/src/AspNetCore/Inc/serverprocess.h#L18. |
Thanks @davidfowl. I'm going to leave the workaround in place for now, but it would be really great if once this new UI is added into VS, the release notes warns us who are using this environment variable that we should probably unset it to avoid the potential light up issues, and use the new UI feature. Thanks again! |
@davidfowl Thanks for letting us know this will soon be opt-in rather than opt-out! However, you mentioned that there will be a UI for this - I'm not sure I udnerstand what you mean, but consider that many of us don't run from VS, so it should be possible to disable without having VS / a UI. Also, please let us know whether @nzain's workaround disables Application Insights, or just hides the logs? |
@grokky1 What exactly are you talking about? It's not on by default. Visual studio sets an environment variable to light the feature up. That's how the system works... |
@davidfowl If it's not on by default then why did many of us find it in our logs? That's how we found this thread to begin with... But you're right I'm not sure how it works, I just want comfort I don't have it running unless I opt-in. |
What logs? In Visual studio or elsewhere?
No problem, that's what I'm here for 😝 . |
@davidfowl For example the debug log as shown above by @Trcx528 and @simonmurdock (which is also how I discovered this). So we wanted to know whether for now, until the changes you mentioned, @nzain's workaround disables it completely or just hides those logs. |
Visual studio output, like I mentioned before. That doesn't just happen when you run any ASP.NET Core application. |
@davidfowl Aaah now I see what you mean. 😄 I was worried it was a runtime thing too. Thanks for the confirmation. Also looking forward to optin/out changes in VS as you mentioned. |
Hi @davidfowl - I'm running VS15.4.0 (Preview 1) and App Insights is definitely being collected and attached to a ASP.NET Core app by default? It's not being sent anywhere but it's there. |
That's correct, it lights up in Visual Studio by default and there's no off switch. You can turn off all light up but that's a big hammer. Still, it's a workaround for now. |
Previously we had the option in Program.cs to include (or not) AI, any reason why we couldn't have something similar going forward? |
The goal of this feature is to enable lighting up AI for diagnostics externally. Things are in place such that it isn't on by default, but various external actions may turn it on without having to touch application code (which is brittle). The problem is that the Visual Studio experience turns it on (only during debugging I believe) by default and doesn't give an option to disable it. |
@davidfowl Now that you've explained it, I feel at ease, especially as you've confirmed we'll soon be able to control it. But put yourself in our shoes. Most of us don't know what AI is, don't need it, and won't ever use it (I admit I too don't fully understand it!). But we know it has something to do with "telemetry", which is such a poisonous word that the Azure team smartly chose the word "insights" instead. My boss doesn't care if it can be disabled/enabled, or whether it's off by default and VS currently intentionally/unintentionally (or due to a bug/oversight) turns it on. All he cared is that we have a potential leak in our IP, which ends up who knows where... And who could blame him. We had major drama. It's the same problem as with EF Core, before they added that environment variable to disable CLI telemetry. The problem is that the docs are always behind the code. So whenever there's telemetry, the docs should explain it to us - keep in mind we don't understand the framework like you do. So when the VS team discovered this issue, they should have come clean and documented it. I know docs aren't your field (your field is "producing the awesome" 😄), but please put pressure on the docs team. If I knew what this feature was and could explain it to my team and my manager, there would have been less "drama". Finding out about it afterwards would make anyone jump to evil conclusions, I hope you see that... For your team it's no biggie (and you may think we're being overly dramatic over nothing), but for your users and their managers, this sort of thing is a major biggie. (So we're clear, the stuff your ASP team does is 101% awesome... And thanks for always taking time to help.) |
I was going to write something similar... Putting my Agile Product Owner hat on, shouldn't this feature be there if requested and work how users need it to work not what MSFT thinks it should do? I've always felt this is the bit of Agile/Lean that MSFT has yet to grasp, working in Sprints and regular releases with tons of new products and features is great but who is asking for them and where is the feedback loop? |
There is like a circular reference, both projects references each other to justify a close status? |
@DenisDollfus I think this thread provides enough explanation/work-arounds to be considered closed |
@Rabadash8820 A fix would be better than workarounds. But actually I missed @glennc last point above stating that "We are adding more obvious options to not turn on app insights when debugging in VS. They will appear in a future update.", which is great. |
We don't track tooling issues on here. |
This is VERY frustrating. With DotNet Core 2.0, ApplicationInsights is being forced on us which is exactly the OPPOSITE of open source. |
@genifycom - btw this is fixed in the latest previews of Visual Studio. There is now a tools option to turn it off. |
@BillHiebert That looks perfect, thanks for sharing. EDIT: Oh yes you wrote "preview". Anyway not deleting my mistake as it provides version number for anyone looking for the fix. |
@DenisDollfus - correct. The change is in a preview of 15.6 |
this has been released in the latest version of Visual Studio 15.6.3. |
Upgrade to ASP.NET Core 2.1 😄 |
@afucher Assuming you are targeting netcoreapp2.0, it looks like you have not installed the 2.0 aspnetcore runtime store. The runtime store is included with the sdk: https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.200 or you can download the ASP.NET Core Runtime individually at https://www.microsoft.com/net/download/dotnet-core/runtime-2.0.8. |
@davidfowl upgrading didn't fix it for me.
My output is still flooded with AI logs. |
Checking "Disable local Application Insights ..." in Tools -> Options worked for me. VS 15.7.5. |
I'm on 15.8.4; "Tools > Options > Projects & Solutions > Web Projects > Disable local Application Insights..." is checked; launchSettings.json has "ASPNETCORE_preventHostingStartup": "True". I still see Application Insights in the Output... |
@RodBarnes same here I pulled the plug by doing: public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
#if !DEBUG
.UseApplicationInsights()
#endif
.UseStartup<Startup>(); in Program.cs |
Ok, so I finally got the debug stream silenced on ASP.NET Core 2.1;
Note the IsTracingDisabled was the key, but I left in DisableTelemetry for good measure plus it's helpful when searching for references between .NET Framework & .NET Core projects in the same solution. |
thanks f2calv, your code work on ASP.NET Core 2.2. |
"Disable local Application Insights for Asp.Net Core web projects" doesn't seem to have any effect on AI in VS 15.9.5, nor does setting |
Same problem, the Disable local Application Insights for Asp.Net Core web projects does not do anything with VS 15.9.4 & .NET Core SDK version 2.1.502 |
At the bottom of the thread referenced by @ghosttie was the key for me, official doc here: https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#disable-telemetry-dynamically |
I've been attempting to familiarize myself with the asp.net core 2.0 stack. I created a new project and with every request I see output from applications insights in the debug window. As this is just for my own learning I have no desire to use application insights and would rather not have it cluttering the debug window.
Most advice I've found says to just remove the nuget package, however AI is not installed via nuget. The only nuget packages installed are
Microsoft.AspNetCore
andMicrosoft.NETCore.App
, neither of which depend on AI. Further more I can not find any reference to AI in my services or appbuilder in my startup. Because the lack of configuration objects and the lack of a nuget package I would expect AI to not be in my project at all, yet it is still logging something.In short, AI is logging to the debug window, even though it appears not to be part of my project. How can I go about disabling this?
The text was updated successfully, but these errors were encountered: