-
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
Traces, logs, correlation are lost when using Arcus.Observability in Azure Functions #336
Comments
Ok, so to recap: using Arcus/Serilog gives diff results than using Microsoft logging solely. |
I am also having this problem. var logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.Enrich.WithComponentName(Constants.ComponentName)
.Enrich.WithVersion()
.Enrich.WithHttpCorrelationInfo(builder.Services.BuildServiceProvider())
.WriteTo.Console()
.WriteTo.AzureApplicationInsights(instrumentationKey)
.CreateLogger(); when I run without the "WithHttpCorrelationInfo", it shows correctly. |
't Was indeed a mistake in the sample. I corrected it. |
@carolinasantos0 What version of Arcus.Observability are you using ? I am using 2.3.0 and with the sample code that I posted here, no requests are logged in App Insights. I can find some traces via 'Transaction Search' in App Insights, but nothing is linked to each other, so it is impossible to display a 'timeline'. As you can see, I'm not even using ´WithHttpCorrelationInfo`. Edit: this is specific for Azure Functions. I do not have these problems with web API's. |
@fgheysels also 2.3.0. |
I'm wondering, if this is a problem of linking/correlation, and we don't use Arcus. Again, HTTP correlation in logging is not yet supported with Arcus. Then, I'm wondering if this is something to do with Arcus, and rather Serilog and/or log levels. Maybe a dedicated meeting should be planned for this. |
@carolinasantos0 , the way you're using the |
I think this will indeed call for a dedicated meeting / more investigation. I can already say that:
It is hard to say whether this is Serilog or Arcus related. Nothing is being logged in the 'request' table in AppInsights. So when you go to the 'performance' blade in AppInsights f.i., , it is just empty. As soon as I remove the Serilog logger usage, it works as expected (as in, requests are logged, and I all related telemetry is linked) |
It looks like it's more working as expected if I do not call the |
When looking at the |
I've done some further investigation:
Therefore, I've decided to mark this method as obsolete. It can be removed in a later phase. (Note that this also has an effect on the |
I have now noticed that traces are written twice to application insights from within my FunctionApp. Needs to be investigated further. |
Hehe, that's strange. 😅 Maybe something with sinks that are registered twice and/or Serilog+Microsoft logging and/or methods that are called twice? |
To be honest, I don't see any duplicated registered sinks, nor do I see duplicatd logging calls. This is how the logger is setup in the public override void Configure(IFunctionsHostBuilder builder)
{
var configuration = builder.GetContext().Configuration;
builder.ConfigureSecretStore(secretStoreBuilder => AddSecretProviders(secretStoreBuilder, configuration));
builder.Services.AddLogging(loggingBuilder => ConfigureLogging(loggingBuilder, configuration));
}
private static void ConfigureLogging(ILoggingBuilder builder, IConfiguration configuration)
{
var logConfiguration = new LoggerConfiguration()
.MinimumLevel.Information()
.Enrich.FromLogContext()
.Enrich.WithComponentName("myname")
.WriteTo.Console();
var telemetryKey = configuration.GetValue<string>("APPINSIGHTS_INSTRUMENTATIONKEY");
if (!String.IsNullOrWhiteSpace(telemetryKey))
{
logConfiguration.WriteTo.AzureApplicationInsights(telemetryKey);
}
builder.AddSerilog(logConfiguration.CreateLogger());
} Also, not everything is logged twice. Some Traces are logged twice, but dependencies are not. (Dependencies that are tracked by the Azure Storage SDK for instance, are appearing only once in AppInsights). There is a slight difference in the trace-text though; look at the quotes. |
I'm wondering if this issue (duplicated entries that are not entirely identical) is because of using the So, as a test, I renamed the |
Ok, wauw, that's kinda strange 🤔 . It's a good thing you found it! |
I'll close this issue, as I've created another issue for the duplicated traces (and other strange things). |
Describe the bug
I have a Timer Triggered Azure Function, in where I use Arcus.Observability (and thus also Serilog) to log to Azure Application Insights.
Although there are traces being logged to Application Insights, they're not correlated. With that , I mean that I cannot get an overview of traces (dependencies, etc... ) that were logged during one Function Invocation.
When I do not use Arcus.Observability and Serilog, everything is nicely linked AND there are things logged that are not logged out-of-the box when using Arcus.
To Reproduce
This is how I setup logging using Arcus:
When the Function runs, I can find all sort of things in App Insights, but correlation info is missing. The traces do not contain any
![image](https://user-images.githubusercontent.com/3605786/154086797-82badef5-0641-444d-acfa-11e714e2cb9d.png)
Operation Id
,Parent Id
headerIf I change the function, so that Arcus.Observability and the AppInsights extension is not used for logging, traces are correlated AND I see things being logged that are not logged when using Arcus.Observability:
In the screenshot above, you can see that there are traces being logged for getting a token; a (SQL) dependency is logged out of the box to Azure Synapse, .... These things are not logged out-of-the-box when I use Arcus.Observability (when using Arcus, I make use of an Arcus extension method to log the dependency myself, but when I do not use Arcus, it is done out-of-the box).
It looks like some traces / dependencies / .... are lost when using Arcus.Observability. Could this have something to do with configured loglevels ? (As you can see, the default loglevel that I've configured is Information).
The screenshot above shows what and how is being logged when we setup logging like this:
(In my settings I have an
APPINSIGHTS_INSTRUMENTATIONKEY
setting that contains the instrumentation-key of App Insights).Expected behavior
All logs are nicely correlated.
All information that is collected out of the box, must be available in App Insights.
The text was updated successfully, but these errors were encountered: