-
Notifications
You must be signed in to change notification settings - Fork 280
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
AI (Internal) Errors when using version 2.8.0 or 2.8.1 in Azure Functions #973
Comments
Hello @Royhoey, thank you for reporting this. As a workaround, please continue to use 2.7.2. What you're seeing is expected behavior, but obviously not customer friendly. The error you're seeing @lmolkova would be able to provide more information when she is back in the office next week. |
Having several sub-applications n the same process is a valid customer scenario. It reproduces in functions and in ServiceFabric. Unfortunately, RichPayloadEventSource attempts to create EventSource each time ApplicationInsights is initialized So I believe this is a bug and fix is to have static event source and never dispose it. It requires some testing as it might not be appropriate solution. @pharring do you know if this approach could work? |
@lmolkova The expectation is that the RPES is a singleton -- at least per AppDomain. Accessed through the |
BTW, this only accounts for one of the error messages from the screenshot. |
Indeed, this is the case. I'll try to repro it and check what happens. AFAIK there is no multi app-domain code in functions. Before function V2 there was no supported way of having explicit AI SDK version different than one implicitly referenced by functions host. Perhaps functions do some magic to load explicit version along with implicit one - I'll check. |
I've experimented with it and was able to repro the issue. Apparently, there are two versions of AppInsights loaded in the same appdomain Microsoft.ApplicationInsights, Version=2.7.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, D:\Program Files (x86)\SiteExtensions\Functions\2.0.12180\32bit\Microsoft.ApplicationInsights.dll Microsoft.ApplicationInsights, Version=2.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, D:\home\site\wwwroot\bin\Microsoft.ApplicationInsights.dll @brettsam @fabiocav is it expected? It should be a common problem for all libs having event sources (i.e. almost all Azure Sdks), so it means some features or diagnostics capabilities are still breken when customer brings their own version of dependency. Am I missing something? |
AFAIK everything works as expected, except showing noisy error messages. The feature that would be affected is service profiler, but I think we don't have it for functions. @pharring is it correct? @Royhoey do you see any issue except messages? As a workaround, can you downgrade explicit AppInsights to 2.7.2? |
Host dependencies are isolated from extensions/user dependencies. If you examine the two assemblies, they'll be loaded in different assembly load contexts. We have automatic unification, but will never downgrade a user/extension assembly to match the host. We do have set of assemblies that we always unify to host versions (if within the same major), but those are primarily framework, ASP.NET and WebJobs core assemblies. We could consider adding AI to this, but we'd essentially be snapping customers to what the host has. |
Thanks for the explanation, @fabiocav! So what happens is that we have two different types of RichPayloadEventSource defined in two different ApplicationInsight dlls and both define the same event source, which is not allowed. For now the resolution is: functions do not support bringing explicit ApplicationInsights dependency with version higher than host has. It seems that loading two different versions of assembly may lead to unpredictable issues similar to this one and there is nothing specific to ApplicationInsights here. |
We haven't had similar issues. From a runtime (CLR) perspective, those are essentially two distinct types. This pattern will become more common with other hosts with similar requirements adopt the new isolation features in .NET Core. What you've confirmed is what I mentioned above; we'll unify within safe ranges, but we'll never downgrade the user. We could add a unification policy for AI, but currently, the behavior means that users would run into this if they're referencing something newer than the runtime. Is the side effect here just failures when with the second event source and noise related to that? Any other impact? |
right, as far as I can tell, there is no impact except the noise so we can tolerate it for now. |
@lmolkova |
When we say we are tolerating this for now? Can you confirm that this is temporary and will be fixed in the future? I ask because this noise is only tolerable in small volume scenarios. We sometimes execute 20+ million functions while ingesting a batch of data. If we're getting this internal traces on every one of them that's a ton of noise that we have to wade through (and that the client has to pay for). The traces don't have any category so we can't even filter them out in App Insights. Right now it sounds like the only work around is to downgrade and that's fine in the short term but not long term. |
@mayoatbm For now, the options are:
We'll simplify p2 a bit and will expose a configuration that disables SDK error collection. |
Thanks for the fast response. That sounds like a thorny problem for sure. A few followup questions/comments?
Thanks again. |
@mayoatbm Thanks for the feedback.
I agree. However always upgrading to user's version of ApplicationInsights could also be problematic. We'll consider different options, but there is nothing planned immediately to solve it.
Both initializers and processors work in V2. What does not work is the ability to access Functions's DI container (Azure/azure-functions-host#3731)
I agree that users should not pay for our bugs. By default there should be no such errors - only some critical issues appear there and these errors intend to indicate something useful for users: problems with configuration or custom code: e.g. some messages indicate that operation was not tracked because of erroneous parameters - this is sent instead of the telemetry and is actionable for users. These errors substitute exceptions as we cannot disrupt normal application flow, but still have to communicate them somehow to users. So, these errors are generally useful and we still want to send them making sure they are actionable and do not create noise. When something unexpected happens, we want to let you disable this feature to minimize the impact. |
Thanks for responding and for being patient with my questions. These are good answers and i feel better about the current situation. We're pretty big users of Azure Functions & App Insights together and we are really looking forward to getting over that integration hump as it would improve our monitoring so much. Thanks again. |
* update base to beta and related changes * read correlation context always
This is an older post, what version does Functions SDK 1.0.29 use? I dont know which version to downgrade to. |
Not sure if you figured this out, but in case someone else has the same problem, I used v2.9.1 and seems to be working for me. I happened upon the page below which seems to confirm they are now using 2.9.1 sdk in Azure v2 functions. |
@pksorensen @tedterrill Please take a dependency on WebJobs SDK, and not directly on ApplicationInsights. This means you'll never have to worry about which version of application insights sdk to use. |
I have the same problem using Microsoft.NET.Sdk.Functions 3.0.3. How can I solve the problem for Azure Function v3? |
Still getting this exceptions with Microsoft.NET.Sdk.Functions 3.0.7 |
Please report these issues to the Azure Functions repo (https://github.com/Azure/azure-webjobs-sdk). @brettsam FYI |
When using TelemetryClient in an Azure Function, AI internal errors are added in application insights.
This does not occur when downgrading to 2.7.2.
Repro Steps
Project file:
Actual Behavior
Traces with AI Internal Errors:
AI (Internal): ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Core: An instance of EventSource with Guid 74af9f20-af6a-5582-9382-f21f674fb271 already exists.
and
AI (Internal): ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Core: Object reference not set to an instance of an object.
Expected Behavior
No AI internal errors
Version Info
Azure Function runtime version: 2.0.12134.0 (~2)
.NET Version : .NET Core 2.1
The text was updated successfully, but these errors were encountered: