-
Notifications
You must be signed in to change notification settings - Fork 14
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
Unwanted traces are logged when using Arcus.Observability in Azure Functions #359
Comments
Hmm, I don't know if it got anything to do with it, or if it's even relevant: we usually move the logging configuration outside the delegate so that the config is created at startup time and not at runtime, when it's requested. |
How do you mean exactly ? |
I am also wondering if other people have seen this behavior as well. |
Instead of: builder.Services.AddLogging(loggingBuilder =>
{
LoggerConfiguration logConfig = ...
...
}); We do this in the template: LoggerConfiguration logConfig = ...
builder.Services.AddLogging(loggingBuilder =>
{
...
}); I was looking at the traces that were 'different' from the rest, and it got me thinking that maybe there was a 'delay' or something that made the traces look the way they do. |
Plus, maybe this #364 is also related to this. Maybe we should remove the |
Thinking more and more that this could also be a cause. We should have a streamlined approach for Azure Functions that work with Arcus Observability (and not rely on anything no there, like built-in support) for service-to-service correlation, probably. |
This indeed sounds reasonable. Can you investigate this further pls ? |
Looked a bit deeper and checked if we still have those strange |
We can close this, right? As we have #364 that will make sure that we don't have Microsoft's stuff anymore. |
Closing for now as the #364 is solving this for us now. |
It seems that this issue is still relevant. |
We'll need some information on what, where, version, and how the logging and telemetry is set up. |
This was also reported here serilog-contrib/serilog-sinks-applicationinsights#157. |
But, when you remove the |
@Pauwelz @fgheysels , just did the test myself with a freshly created template and indeed saw these duplicate lines. {
"logging": {
"logLevel": {
"Host.Function": "None"
}
}
} |
@tleblanc159 posted a possible solution here: serilog-contrib/serilog-sinks-applicationinsights#157 (comment) We should definitely check this out |
I posted that solution here at first but wasn't sure if it really fit this issue. Afaik, the Arcus HTTP Triggered In-Process Function App template uses an extension method provided by Arcus to completely remove the Azure WebJobs Host provided ApplicationInsightsLoggerProvider. The solution I posted is a way to interop with that instead of completely removing it. To me, it seems like interop-ing would defeat the purpose of using Arcus since Arcus would no longer be in control of all logs produced by the In Process Function App (which kinda seems like the whole point of using Arcus.Observability). At that point, you may as well use the Serilog Application Insights sink instead, like in the solution of mine you linked. |
The Arcus Serilog Application Insights sink does more than only pass logs to Application Insights; it makes sure that you can write telemetry (requests, dependencies, metrics, events) right from the logging framework and let's you include contextual information. |
I see, that makes a lot more sense now. I misunderstood the use case of Arcus.Observability. The solution I posted should be extensible to Serilog using the Arcus App Insights sink. Could even take it a step further and create a custom implementation of ILoggerFactory that doesn't allow the Az Func Host App Insights LoggerProveder to be added to the factory, allow adding of all registered LoggerProviders + any more that you specify (anything that logs to App Insights), remove reliance on LoggerFactory class since it might already be registered and used in an incompatible way. Maybe just an extension method on ILoggerBuilder (if one for Arcus doesn't exist already) could handle most of that and then be used to configure the LoggerBuilder instance. Or both. |
Seems like the proposed way to do Application Insights in isolated Azure Functions, is with their dedicated Application Insights package: Can you try to add this, @fgheysels , alongside our Arcus stuff, and see what comes up? You'll have to use the |
Conclusion: create preview package of |
I have setup logging to Application Insights using Arcus.Observability and Serilog like this:
This works as expected, but there are some weird things to be noticed:
The traces table in Application Insights contains (null) entries:
Some traces are written twice to Application Insights, albeit slightly different (look at the quotes)
![image](https://user-images.githubusercontent.com/3605786/159495543-0c26508a-28c0-42a7-9cab-e5450d2abd9e.png)
The text was updated successfully, but these errors were encountered: