Description
After upgrading from version 4.0.0 to version 4.1.0 of Serilog.Sinks.ApplicationInsights we do not get Operation name in Application Insights for traces that are written during handling of Rebus messages.
Unsure if this is a bug or an intended change in behavior. I have verified that it is the NuGet package Serilog.Sinks.ApplicationInsights causing the problem by installing version 4.0.0 instead and then it works as before.
Reproduction
Here is the code we use for configuring the logging.
private static void ConfigureLogging(IUnityContainer container, IConfiguration configuration)
{
var loggerConfiguration = BasicLoggerConfiguration();
var appInsightsConnectionString = configuration.GetConfigurationSettingValue("ApplicationInsights.ConnectionString");
if (!string.IsNullOrEmpty(appInsightsConnectionString))
{
loggerConfiguration = loggerConfiguration.WriteTo.Conditional(
e => e.Level >= LogEventLevel.Information,
c => c.ApplicationInsights(container.Resolve<TelemetryConfiguration>(), TelemetryConverter.Traces, LogEventLevel.Information));
}
Log.Logger = loggerConfiguration
.WriteTo.Console()
.CreateLogger();
Trace.Listeners.Add(new SerilogTraceListener());
}
private static LoggerConfiguration BasicLoggerConfiguration()
{
var config = new LoggerConfiguration()
.Enrich.With<SourceInformationEnricher>()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Rebus.Pipeline.Receive.DispatchIncomingMessageStep", LogEventLevel.Debug)
.MinimumLevel.Override("Rebus.Pipeline.Send.SendOutgoingMessageStep", LogEventLevel.Debug);
return config;
}
Then we as an incoming step for Rebus creates a RequestTelemetry
var requestTelemetry = new RequestTelemetry
{
Name = $"Dequeue {this.endpointName} | {headers[Headers.Type]}"
};
If we then log a trace inside a message that is handled, we get this problem.
public async Task Handle(SomeMessage message)
{
Log.Information("Some test log");
}
Expected behavior
Expected Operation name to still have the value set.
Relevant package, tooling and runtime versions
We run the application as a WebJob instance in Azure. It is using .NET Core and .NET 9.
Relevant NuGet package versions (hope I included what is relevant, otherwise just ask)
- Microsoft.ApplicationInsights, 2.23.0
- Microsoft.Azure.WebJobs, 3.0.43
- Rebus, 8.9.0
- Rebus.Serilog, 8.1.0
- Serilog, 4.3.0
- Serilog.AspNetCore, 9.0.0
- Serilog.Sinks.ApplicationInsights, 4.1.0
- Serilog.Sinks.Console, 6.1.1
- Serilog.Sinks.Debug, 3.0.0
- SerilogTraceListener, 3.2.0
Additional context
The start of the message handling is logged as a request telemetry and it has the Operation name set correctly as before. It is trace logging done as part of the handling of the message, as for instance Log.Information("Some test log");, that is missing the Operation name.
Description
After upgrading from version 4.0.0 to version 4.1.0 of Serilog.Sinks.ApplicationInsights we do not get
Operation namein Application Insights for traces that are written during handling of Rebus messages.Unsure if this is a bug or an intended change in behavior. I have verified that it is the NuGet package Serilog.Sinks.ApplicationInsights causing the problem by installing version 4.0.0 instead and then it works as before.
Reproduction
Here is the code we use for configuring the logging.
Then we as an incoming step for Rebus creates a RequestTelemetry
If we then log a trace inside a message that is handled, we get this problem.
Expected behavior
Expected
Operation nameto still have the value set.Relevant package, tooling and runtime versions
We run the application as a WebJob instance in Azure. It is using .NET Core and .NET 9.
Relevant NuGet package versions (hope I included what is relevant, otherwise just ask)
Additional context
The start of the message handling is logged as a request telemetry and it has the
Operation nameset correctly as before. It is trace logging done as part of the handling of the message, as for instanceLog.Information("Some test log");, that is missing theOperation name.