-
Notifications
You must be signed in to change notification settings - Fork 191
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
Correct way to use Application Insights in v4 and .Net 6 #760
Comments
@emilssonn Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights seems to be non-working. https://github.com/Azure/azure-functions-applicationinsights-extension/tree/main/src/Worker is literally empty except for a csproj. I'm not sure quite sure how to parse Azure/app-service-announcements#346 (comment), but it appears that Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights isn't supposed to be used at this point. In any case we're experiencing the same issue as you. Rudimentary trace logging is performed for external calls, but they are not tracked as dependencies (without using Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights). |
@emilssonn It appears to work if you follow the steps at https://docs.microsoft.com/en-us/azure/azure-monitor/app/worker-service#using-application-insights-sdk-for-worker-services, that is get the |
I am 99.9% sure I saw some official documentation about But I still cannot find any official documentation about .Net isolated functions running .Net 6 and v4. |
Leaving this assigned to @brettsam as he is driving the logging enhancements activities. |
Hi, so finally what happened with Application Insights for Azure Function V4 and .net 6? |
I'm facing a migration but hesitant until know this issue is resolved. |
+1 on this. I'm facing similar issues with dependency telemetry in dotnet-isolated in functions v4, .net 6. |
In short -- we abandoned that approach due to startup performance and I don't believe it would have given you everything you were looking for here anyway. When you enable Application Insights from the portal (or add the However, there are some other scenarios that this does not cover -- dependency tracking in the worker; access to Ideally, the |
+1 on this. We are also facing this issue. We use the |
@brettsam Apart from dependency tracking in the worker and access to These issues have been discussed in other github issues aswell. The logging issues are a major problem |
In my case, Logs were showing in Trace and locally. But the Function's Monitor wasn't logging. |
We are having the same issue using |
From what we can see from our tests |
we can't get Azure pipelines to build correctly with in both cases the error is |
Are there any updates on this issue? Lack of correlated dependencies is a major concern as is lack of documentation on enabling this in general. |
I've just run across this issue as I'm digging into my Azure Function application insights telemetry. We're running functions v4 (dotnet-isolated) and .net6.0. To be honest, I would expect this to be resolved already, since Az Functions v4 has gone GA @brettsam can you give us an update on when we'll have access to TelemetryClient etc? |
Considering that .net core 3.1 is end of life in December 2022, and .net core 5 is already end of life, this needs to be pushed to the forefront. Requiring organizations to migrate/upgrade to v4/core 6 but losing basic functionality is just terrible. |
Been having this issue for some time now. We are on Functions v4 and .NET 6. Please resolve this quickly. |
We have used this way: #822 (comment) |
This is really starting to become very problematic, to the point we're considering ditching Application Insights and using something else. We're in a situation where we cannot investigate/analyse live data. Running .net 6 in Isolated Process functions. These are the things causing problems:
An update on when all of this is going to be sorted would be appreciated as it's getting to the point where we have to seek alternatives. |
I've just spent 3.5 months going round in circles with customer support on this only to finally discover app-insight dependencies are "not supported" for isolated functions :-( Could we at least get the documentation improved to make it obvious this is a limitation? |
Many have already started the obvious - for a GA-ed product this SDK is in a poor state. With serverless that is hosted and managed by Azure, logging and telemetry is a vital tool for troubleshooting. Without it functioning properly clients are running with blinders on. Detailed documentation, functioning Appinsights integration, and fixed related issues should keep the team up at night. Untill then, it's their customers are the ones that are staying up. |
Design for this is in process. We'll be sharing details here once that is reviewed. Moving to 125 to track the completion of this work. |
+1 for facing the same issue. In my Azure function (dotnet-isolated version 4.0), I used Opentelemetry to track postgresql dependency calls, which show up correctly in AppInsights however they aren't correlated with the parent request. I tried the below code in Azure Function -> Program.cs -> main -> ConfigureServices Usings
|
This comment was marked as off-topic.
This comment was marked as off-topic.
The preview packages are now available: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ApplicationInsights. For usage and explanation, see the PR here (official docs will come when this is out of preview): #944. If you have feedback, bugs, etc, please create a new issue with the details and we'll take a look. |
@brettsam I have used preview package and sample code provided in the PR link today. I still see all dependencies not linked to the parent. The parentId set in dependencies does not correspond to any telemetry objects logged in our appinsights. |
@LenaVinogradov -- can you open a separate issue with exactly what you're seeing and what you expect to see? That'd help us narrow it down. Thanks! |
So I'm trying this new preview package locally and in Azure with a .Net 6 function v4 isolated test project. So everything is brand new/green field/new project template. I installed the package and changed the var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(builder =>
{
builder
.AddApplicationInsights()
.AddApplicationInsightsLogger();
})
.Build();
host.Run(); The azure portal generated application insights for me and configured the function app. |
Hi, Azure Function v4, .Net 6 isolated. |
Hello, I'm also struggling like cracy to get the trace and debug log work: TL;DR:Using an in process function. The out the box logging works fine (even structures the log a bit). But in isolated I don't get any structure, and Traces and Debugs are not logged. Not in console - not in application insight. With a few config in progam.cs I can get a structured log going - but no way traces and debug. The simplest possible solutions:I've created a repo with what works, and what doesn't In Process Example that worksThe host file log level it default set to trace The HttpExample.cs logs both information, trace and debug: log.LogInformation("Log Request number {InfoLogCount}", 1);
log.LogTrace("A little trace in the middle");
log.LogDebug("A littel debug info in the middle");
log.LogInformation("Log Request number {InfoLogCount}", 2); And this results in expected logs in both "console" And even structures the log somewhat: Now using an isolated approachAnd with the same log events, the trace and debug doesn't get logged: and not in Application insights: The base implementation doesn't handle the structured logging: Adding reference to |
At the moment it's a mess. It is totally unclear using a function in Isolated Mode what is the right/correct way to log to Application Insights. |
Hey everyone -- I'm going to lock this issue down as it's getting hard to track the individual issues. I'll respond to everything that's here now and spin off new issues if needed, but please create a new issue with your questions/bugs from now on. Thanks for all the feedback! |
Reply to: #760 (comment)
The worker should behave just like any other Console application in .NET. You can adjust logging levels and filters via code, appsettings.json, etc -- https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-6.0#configure-logging. Maybe the confusing thing here is that there is now two parts to logging configuration: the host and the worker. The host is controlled by Please open a new issue with details if this doesn't help -- or if you don't like it :-) I can go into some reasoning there, if needed. |
Reply to: #760 (comment) @vasylstrogushr -- can you share a repro in a new issue? We're not doing anything special when we add the App Insights Logger, so I'd expect it to behave exactly the same way. One thing that I did realize (and will update shortly) is that the App Insights logger injects an extra filter into the logging system to log only at Warning and above. I spent a while trying to figure out why my Information logs didn't appear anywhere, too: |
Reply to: #760 (comment) @vasylstrogushr -- Can you open a new issue with a small repro to explain the scenario? I can get the right App Insights people to help out there. Are you saying that logs from the separate service are not being correctly correlated? |
Reply to: #760 (comment) @lund76 -- you may be hitting the same thing that I mentioned above in #760 (comment) (that host.json only applies to the host). The worker is a separate Console application and it's completely configurable like any other Console application. Please feel free to file a new issue if this doesn't help or you have feedback. I'll give a little overview of our reasoning here: The host.json logging settings are very .NET-specific in their structure. We could load them directly and apply them to the dotnet-isolated application with no problem. But that isn't a great solution for any other language, so we're experimenting with the notion of having the worker control its own logging in its "natural" way and the host being controlled separately via host.json (it is called host configuration, after all). This allows you to write filtering code in .NET, apply different log levels to things in host vs worker, etc. And you don't have to think about how two conflicting settings between the host and worker will compose together... the worker ignores host.json completely. As mentioned above, we welcome feedback here, so feel free to file a new issue. We're trying to rationalize the logging configuration for out-of-proc workers and realizes this can be confusing for those coming from the in-proc world. |
Reply to: #760 (comment) @olandese -- see the "preview doc" at #944 (comment). I think it answers all of your questions. If not, please file a new issue with your questions that are unanswered, and I can help out there. |
Closing this now as the preview package is released and it's tough to track the one-off comments here. If you run into issues, have questions, or general feedback, please file a new issue. Package: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ApplicationInsights |
From reading different issues, discussions and documentation from the past months, it is still unclear to me how to correctly use/install Application Insights in a .Net isolated function running .Net 6 and v4.
I have tested with the nuget Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights. The absolute most basic features of application insights works with this nuget. But no dependency tracking etc.
Where can I find the correct documentation for using Application Insights with a .Net isolated function running .Net 6 and v4? Including depedency tracking, log levels filter, using TelemetryClient and TelemetryConfiguration in code.
The text was updated successfully, but these errors were encountered: